Bug in JLS specification for restriction on where a return statement is allowed.
Ted Neward
ted at tedneward.com
Thu Dec 3 22:02:20 PST 2009
Cant it be argued that the return doesnt appear within the instance or
static initializer, but within a construct which happens to be inside an
initializer? (Meaning the text is, at best, ambiguous?)
Not trying to nit-pick, just trying to understand how deeply detailed the
specification needs to be, to be honest.
Ted Neward
Java, .NET, XML Services
Consulting, Teaching, Speaking, Writing
http://www.tedneward.com
From: compiler-dev-bounces at openjdk.java.net
[mailto:compiler-dev-bounces at openjdk.java.net] On Behalf Of Neal Gafter
Sent: Wednesday, December 02, 2009 9:24 AM
To: Alexander Buckley
Cc: OpenJDK
Subject: Bug in JLS specification for restriction on where a return
statement is allowed.
Alex-
JLS 14.17 says
A compile-time error occurs if a return statement appears within an instance
initializer or a static initializer (§8.7)
<http://java.sun.com/docs/books/jls/third_edition/html/classes.html#39245> .
However, javac allows a return statement within an instance or static
initializer if there is an intervening nested inner class with a method.
static { // static initializer
class X {
void foo() {
return; // yet return allowed within it
}
}
}
I believe this is a bug in the specification.
Cheers,
Neal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20091203/db8cde2e/attachment.html
More information about the compiler-dev
mailing list