goto in Java bytecode

后端 未结 9 672
一向
一向 2020-12-16 11:58

So the other day when I was looking at the wikipedia page for Java bytecode I came across this example:

Consider the following Java code:

9条回答
  •  鱼传尺愫
    2020-12-16 12:18

    You should distinguish between language keyword goto and byte code or assembly instruction goto.

    It is bad practice to use goto jumps in high level code, like in C. Therefore it is not allowed in Java.

    The original Edsger W. Dijkstra paper on goto.

    In compiled code usage of unconditional jump instruction goto is completely OK. It is put in there by compiler and it does not forget about implications of jumping around the code including initialization of data, deallocating memory etc.

提交回复
热议问题