ashu ashu - 1 year ago 56
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
statements if
doesn't compile?

Answer Source

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