Why there cannot be multiple exit points from a static initializer? Does Java Language specification state so?
When trying to compile code as:
class HelloWorldApp {
static {
if(1 > 2)
return;
System.out.println("static");
}
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Compiler prints out an error: return outside method
Java disassembly with javap
shows that static
is a void method, so would it be possible, theoretically, to create a bytecode that would have multiple 'returns'?