달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

'for'에 해당되는 글 1

  1. 2013.04.11 자바 소스 디컴파일 해보기.
2013. 4. 11. 15:05

자바 소스 디컴파일 해보기. 그거/Java2013. 4. 11. 15:05


서버에 있는 class 파일과 PC 에 있는 class 파일의 크기가 달라서

서버의 class 파일과 PC의 class 파일을 decompile 해서 비교하다 보니 아래와 같이 알 수 없는 문장(?)들이 있어서


        break MISSING_BLOCK_LABEL_361;

        Exception exception;

        exception;

        if(bw != null)

            bw.close();

        throw exception;

        if(bw != null)

            bw.close();

그래서, decompile 테스트 해봤다.


BufferedReader br = null;

try {

System.out.println("try >>");

br = new BufferedReader(new InputStreamReader(System.in));

br.readLine();

System.out.println("try <<");

} catch(Exception e) {

System.out.println("catch >>");

e.printStackTrace();

System.out.println("catch <<");

} finally {

System.out.println("finally >>");

if( br != null ) {

try { 

System.out.println("finally try >>");

br.close(); br = null; 

System.out.println("finally try <<");

} catch(Exception ignr) {

System.out.println("finally catch");

}

}

System.out.println("finally <<");

}

System.out.println("000");

ArrayList list = new ArrayList();

for(int i = 0; i < list.size();) {

Object o = list.get(0);

break;

}

System.out.println("111");


int j = 0;

if( j < list.size() ) {

Object o = list.get(0);

}

System.out.println("222");


for(int i = 0; i < list.size(); i++) {

Object o = list.get(i);

}

System.out.println("333");


위의 자바 소스를 컴파일 한 후 class 파일을 디컴파일 해보면 아래와 같다.


        BufferedReader bufferedreader = null;

        System.out.println("try >>");

        bufferedreader = new BufferedReader(new InputStreamReader(System.in));

        bufferedreader.readLine();

        System.out.println("try <<");

        System.out.println("finally >>");

        if(bufferedreader != null)

            try

            {

                System.out.println("finally try >>");

                bufferedreader.close();

                bufferedreader = null;

                System.out.println("finally try <<");

            }

            catch(Exception exception)

            {

                System.out.println("finally catch");

            }

        System.out.println("finally <<");

        break MISSING_BLOCK_LABEL_234;

        Exception exception1;

        exception1;

        System.out.println("catch >>");

        exception1.printStackTrace();

        System.out.println("catch <<");

        System.out.println("finally >>");

        if(bufferedreader != null)

            try

            {

                System.out.println("finally try >>");

                bufferedreader.close();

                bufferedreader = null;

                System.out.println("finally try <<");

            }

            catch(Exception exception2)

            {

                System.out.println("finally catch");

            }

        System.out.println("finally <<");

        break MISSING_BLOCK_LABEL_234;

        Exception exception3;

        exception3;

        System.out.println("finally >>");

        if(bufferedreader != null)

            try

            {

                System.out.println("finally try >>");

                bufferedreader.close();

                bufferedreader = null;

                System.out.println("finally try <<");

            }

            catch(Exception exception4)

            {

                System.out.println("finally catch");

            }

        System.out.println("finally <<");

        throw exception3;

        System.out.println("000");

        ArrayList arraylist = new ArrayList();

        int i = 0;

        Object obj;

        if(i < arraylist.size())

            obj = arraylist.get(0);

        System.out.println("111");

        i = 0;

        if(i < arraylist.size())

            obj = arraylist.get(0);

        System.out.println("222");

        for(int j = 0; j < arraylist.size(); j++)

        {

            Object obj1 = arraylist.get(j);

        }


        System.out.println("333");

        return;


디컴파일한 소스를 보면 finally 가 3번이나 나온다.

그리고, 1번만 실행되는 for문(2번 이상 실행되지 않는 for문)은

알아서 for 문의 조건만 포함한 if문으로 변경된다.


아. 젤 위에 있는 이상한 문장(?)들은 catch 와 finally 에 있는 코드들인듯 하돠.

뭐 새로울 건 없지만, 소스 분석하다가 재밌어서 올려봄.. ㅡ,.ㅡ;

'그거 > Java' 카테고리의 다른 글

JSP 의 EL 과 JSTL  (0) 2013.08.09
enum 사용하기  (0) 2013.05.02
Runtime Data Access  (0) 2012.07.30
NoClassDefFoundError vs ClassNotFoundException  (0) 2011.10.11
Eclipse 에서 Maven 이용해서 remote repository 에 deploy 하기  (0) 2011.10.05
:
Posted by 뽀기