Search code examples
javadecompiler

decompiled code is different from original code


I decompiled a .jar file using jd-gui and checked codes, I found it different from original .java file.

  • original code

    if ( total != 0 ) {
        result[ i ] = bdResult.multiply( bdItem ).divide( bdTotal, 0,
        RoundingMode.DOWN ).setScale( 0, RoundingMode.DOWN ).intValue();
    }
    
  • decompiled code

    if (total == 0)
      continue;
    result[i] = bdResult.multiply(bdItem).divide(bdTotal, 0, 
    RoundingMode.DOWN).setScale(0, RoundingMode.DOWN).intValue();
    

Why this happens?

In addition, decompiled code seems grammatically wrong( where curly bracket goes?)


Solution

  • It's impossible to get the original code by decompiling just because different code can lead to the same java byte code statements. However, you are getting an equivalent version which performs exactly the same actions as the original.