Sunday, July 4, 2010

Bytecode - "How it looks???????? ????? !!!!!"

Hi.....friends,

So,..............in our mind, we have some confusion that how actually byte code looks????
Some people says, it is just like 0 and 1 but the question is 0 and 1 are represents the machine code.
Here, I tried to solve this puzzle with showing this image.

  Lets do some practice by simple java program.

public class SimpleProgram
{
    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }
}

ok. So what? What about byte code?


The Resulting Byte Code

Compiled from "SimpleProgram.java"
public class SimpleProgram extends java.lang.Object{
public SimpleProgram();
  Code:
   0: aload_0
   1: invokespecial #1; //Method java/lang/Object."":()V
   4: return

public static void main(java.lang.String[]);
  Code:
   0: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
   3: ldc #3; //String Hello World!
   5: invokevirtual #4; //Method java/io/PrintStream.println:(Ljava/lang/String;)V
   8: return

}


No comments: