title: Decompiler tools modify the source code for .class file in java
body: <p>I used <strong>DJ JAVA DECOMPILER</strong> tool to get back the <strong>source code</strong> from <strong>.class file</strong> in java. What the source file it generated was having <strong>different code</strong> than what i coded earlier in the <strong>original source program</strong>.</p>
  
  <p>What my doubt is:</p>
  
  <ol>
  <li>Is this because of JVM does code optimization before creating the
  target code for better execution speed &amp; reduce space and time
  complexity?</li>
  <li>Or the decompiler tool modify the .class file code to generate the
  source program again?</li>
  </ol>
  
  <p>See the original source program was this:</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.sql.Statement;
  import java.util.Scanner;
  
  
  public class Test1 {
      /**
       * @param args
       * @throws SQLException
       * @throws ClassNotFoundException
       */
      public static void main(String args[]) throws SQLException, ClassNotFoundException{
          Class.forName("oracle.jdbc.driver.OracleDriver");
          Connection con= DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:choxx","choxx","choxx");
          if(con==null){
              System.out.println("not established");
          }else{
              System.out.println("established");
          }
  
          Statement st= con.createStatement();
          //st.executeQuery("create table student if not exists(sno number(10), name varchar2(30), addr varchar(20))");
          if(st!=null){
              System.out.println("table created..");
          }
  
          st.execute("delete from student where addr='hyderabad'");
          ResultSet rs= st.executeQuery("select * from student");
          while(rs.next()){
              System.out.println(rs.getInt(1)+"   "+rs.getString(2)+"   "+rs.getString(3));
          }
  
  
      }
  }
  </code></pre>
  
  <p>After decompilation what i got is:</p>
  
  <pre><code>// Decompiled by DJ v3.12.12.99 Copyright 2015 Atanas Neshkov  Date: 29-03-2015 10:55:31
  // Home Page:  http://www.neshkov.com/dj.html - Check often for new version!
  // Decompiler options: packimports(3) 
  // Source File Name:   Test1.java
  
  import java.io.PrintStream;
  import java.sql.*;
  
  public class Test1
  {
  
      public Test1()
      {
      }
  
      public static void main(String args[])
          throws SQLException, ClassNotFoundException
      {
          Class.forName("oracle.jdbc.driver.OracleDriver");
          Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:choxx", "choxx", "choxx");
          if(con == null)
              System.out.println("not established");
          else
              System.out.println("established");
          Statement st = con.createStatement();
          if(st != null)
              System.out.println("table created..");
          st.execute("delete from student where addr='hyderabad'");
          for(ResultSet rs = st.executeQuery("select * from student"); rs.next(); System.out.println(rs.getInt(1) + "   " + rs.getString(2) + "   " + rs.getString(3)));
      }
  }
  </code></pre>