Is there a java compiler flag that allows me to use goto
as a valid construct? If not, are there any third-party java compilers that supports goto
?
JVM support goto at bytecode level. If you are doing your own language, you should use libraries like BCEL or ASM, not generating .java file.
You can write your code generator to target Jasmin. You can use goto in Jasmin as much as you like. :-)
Java does not allow using goto
keyword. However, it allows using labels and using break
or continue
with label instead of goto
. In facts, Java is not a language without goto statement, but a language with uncomfortable implementation of it.
By definition, no Java compiler allows goto. Java compilers must implement the JLS, and the JLS does not allow gotos. However, it is also clearly possible to compile a language with gotos to the JVM. AMPC is one C-to-JVM compiler that claims to support C89.
Also note that Java bytecode has a goto instruction, though it's obviously instruction-based not line-based.
Apache Thrift can be used to generate source code in different programming languages from a single source. http://incubator.apache.org/thrift/
You shouldn't, ever, use goto, as it's EVIL ;-)
More seriously, maybe you could have a look at the famous article from E. Dijkstra : http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html