Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

진격의안드로이드&Java

From ZeroWiki
Revision as of 16:13, 27 June 2013 by imported>novaman

강의록

강의 내용

ByteCode.java

// Compile
// notepad++ 에서 UTF8(BOM 없음) 선택후 다음과 같이 cmd에서 컴파일
javac -encoding utf8 ByteCode.java
// Decompile
javap -c ByteCode.class
public class ByteCode{
	public ByteCode() {
		System.out.println("hello");
	}
	
	public void methodOperandStack(){
		int a, b, c;
		a = 5;
		b = 1;
		c = a + b;
	}
}
public class ByteCode{
	public ByteCode() {
		System.out.println("hello");
	}
	
	public void methodOperandStack(){
		try{
			int a, b, c;
			a = 5;
			b = 1;
			c = a + b;
		} catch(Exception e){
		}
	}
}

3차 수정

public class ByteCode{
	public ByteCode() {
		System.out.println("hello");
	}
	
	private static final boolean optimize = false;
	private final void methodOperandStack(){
		if(optimize){
			int a, b, c;
			a = 5;
			b = 1;
			c = a + b;
		} 
	}
}
// Compile 결과

Compiled from "ByteCode.java"
public class ByteCode {
  public ByteCode();
    Code:
       0: aload_0
       1: invokespecial #1                  // Method java/lang/Object."<init>":
()V
       4: getstatic     #2                  // Field java/lang/System.out:Ljava/
io/PrintStream;
       7: ldc           #3                  // String hello
       9: invokevirtual #4                  // Method java/io/PrintStream.printl
n:(Ljava/lang/String;)V
      12: return
}