-2

I tried de-compiling a Java file but instead of giving the exact code the de-compilation gave me was a code that was using goto statements and label

Now i want to extract the code that was used. Can anyone help?

@Override
public int getItemViewType(int i)
{
    int j = 1;
    if (!displaySearchField || i != 0) goto _L2; else goto _L1
_L1:

    j = 0;
_L4:
    return j;
_L2:
    int k = i;
    if (displaySearchField)
    {
        k--;
    }
    if (!(items.get(k) instanceof Group))
    {
        continue; /* Loop/switch isn't completed */
    }
    if (displaySearchField) goto _L4; else goto _L3
_L3:
    return 0;
    if (!displaySearchField) goto _L4; else goto _L5
_L5:
    return 2;
}
Amit Hooda
  • 2,133
  • 3
  • 23
  • 37

2 Answers2

1

Never trust the output from a decompiler. Even if it compiles cleanly. Even if you can run the same unit test suite against the original and the round-tripped versions with identical results.

Never attempt to manually "fix" problems with the decompiled code. If you find yourself thinking, "hmm, this looks almost right... I think I can fix this," STOP. Do not do that.

Sincerely,

Someone who has written a decompiler.

Mike Strobel
  • 25,075
  • 57
  • 69
0

You cannot use de-compiled code. After you write code, when it gets compiled, some code is added by android also. when you decompile, you will be offered that changes. so ur getting errors.

Sush
  • 3,864
  • 2
  • 17
  • 35
  • I know this thing but this code can be changed accordingly to get the original code, so can you help me in that ? – Amit Hooda Dec 27 '13 at 10:05
  • no.. its painful and you dont know wt was the exactly code written, where all it got changed. android does some compression kind of things in which it removes code which is not use full or not needed at all. i tried once, everything going over head so didn't tried after that. – Sush Dec 27 '13 at 10:29