Bug in JLS specification for restriction on where a return statement is allowed.

Neal Gafter neal at gafter.com
Wed Dec 2 09:24:05 PST 2009


JLS 14.17 says

A compile-time error occurs if a return statement appears within an instance
initializer or a static initializer

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20091202/c82d9838/attachment.html 

More information about the compiler-dev mailing list