ashu ashu - 3 months ago 15
Java Question

Why do Java decompilers generate code with gotos?

After decompiling a .jar file, I saw this line in the resulting Java code:

for (Iterator i = val.getparts(); i.hasNext(); goto 135)


What does this mean? Why does decompiled Java code contain
goto
statements if
goto
doesn't compile?

Answer

i used decompiler

Decompilers don't know the fact that goto is invalid in Java source files. It appears in jars and classfiles because compilers use it to implement the following at bytecode level:

  • if-else statements
  • Loops
  • Switches
  • try-catch-finally blocks
Comments