[groovy-user] Anonymous nested try/catch on same exception class

16 views
Skip to first unread message

Jürgen Hermann

unread,
Oct 16, 2007, 7:13:44 AM10/16/07
to us...@groovy.codehaus.org
Hi, I regard the following as unexpected, though it's easily fixed by naming the exception objects dummy1, dummy2, ... JIRA?

> groovy -version
Groovy Version: 1.1-rc-1 JVM: 1.6.0_01-b06
> cat x7.groovy
import javax.management.InstanceNotFoundException;

try {
} catch (InstanceNotFoundException) {
try {
} catch (InstanceNotFoundException) {
}
}

> groovy x7.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, x7.groovy: 6: The current scope already contains a variable of the name InstanceNotFoundException
@ line 6, column 7.
} catch (InstanceNotFoundException) {
^

1 error


Ciao, Jürgen

--
1&1 Internet AG · Brauerstrasse 48 · D-76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger,
Matthias Greve, Robert Hoffmann, Norbert Lang, Achim Weiss, Thomas Gottschlich
Aufsichtsratsvorsitzender: Michael Scheeren

---------------------------------------------------------------------
To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Guillaume Laforge

unread,
Oct 16, 2007, 7:32:13 AM10/16/07
to us...@groovy.codehaus.org
You should either do catch (e) or catch (InstanceNotFoundException
infe), but not just the type won't work. The runtime believes in your
case that InstanceNotFoundException is a variable name, not a class.


--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com

Reply all
Reply to author
Forward
0 new messages