syntax - JAVA: if without curly brackets, and relation to continue -


i have following java code fragment

while (condition1){     switch (someinteger){         case 1:             if(condition2) continue;             // other stuff here             break;         // other cases here     } } 

all fine. when generate class file , decompile using free tool (jd-gui), following code.

while (condition1){     switch (someinteger){         case 1:             if(!condition2);             // other stuff here             break;         // other cases here     } } 

so changes if(condition2) continue; if(!condition2); not find info on other if statement (without braces). can explain logic here? in advance.

edit: did more tests , decompiler not work correctly.

here code before:

public void strip(inputstreamreader f1, outputstreamwriter f2) throws ioexception{     int commenton=0, quoteon=0;     int b1;     while ((b1 = f1.read()) != -1){         switch ((char) b1){             case '\\':                     if (commenton==0){                             quoteon = 1;                             break;                     }                     continue;             case '\n':                     if (commenton>0){ commenton=0; continue; }                     break;             case '%':                     if (commenton>0) continue;                     if (quoteon>0) { quoteon=0; break; }                     commenton=2;                     continue;             default:                     if (commenton>0) continue;                     if (quoteon>0) quoteon=0;                     break;         }         f2.write(b1);     } } 

here decompiled code

public void strip(inputstreamreader f1, outputstreamwriter f2) throws ioexception { int commenton = 0; int quoteon = 0;  while ((b1 = f1.read()) != -1) {   int b1;   switch ((char)b1)   {   case '\\':     if (commenton == 0);     quoteon = 1;     break;   case '\n':     if (commenton <= 0) break label109; commenton = 0; break;   case '%':     if (commenton <= 0);     if (quoteon > 0) { quoteon = 0; break label109: }     commenton = 2;     break;   }   if (commenton <= 0);   if (quoteon > 0) quoteon = 0;    label109: f2.write(b1); } } 

sorry bothering everyone. :p i'll try delete question if can.

it near impossible decompilers reconstruct original syntax working off compiler's interpretation of code.

you write java code, gets compiled byte code java compiler.

a decompiler attempts create java code byte code.

since 2 code fragments logically same, decompiler has done it's job.

edit (saw comment):

actually, it's quite possible (and pretty common) decompiler has made error.

the statement if(!condition2); has no effect whatsoever (provided condition2 indeed boolean , not pseudo code).

therefore first //other stuff here processed regardless of condition2 in decompiled version.

are sure decompiled code works correctly?


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -