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 | package testpackage; public class ReflectionTest { public static void main(String[] args) { Callee callee = new Callee(); callee.printB(); } } class Callee { public void printA() { StackTraceElement stackTraceElements[] = ( new Throwable()).getStackTrace(); for ( int i = 0 ; i < stackTraceElements.length; i++) { System.out.println(stackTraceElements[i]); } System.out.println( "A is called" ); } public void printB() { System.out.println( "B is called" ); printA(); } } |
1 2 3 4 5 | B is called testpackage.Callee.printA(ReflectionTest.java: 14 ) testpackage.Callee.printB(ReflectionTest.java: 23 ) testpackage.ReflectionTest.main(ReflectionTest.java: 7 ) A is called |
'Archive' 카테고리의 다른 글
Reflection을 사용한 String Destroyer (0) | 2011.11.16 |
---|---|
Java에서 메소드명(String)으로 메소드 호출하기 예제 (Reflection API) (0) | 2011.11.16 |
Java에서 메소드명(String)으로 메소드 호출하기 (0) | 2011.11.16 |
Java에서 generic의 array를 허용하지 않는 이유 (Type Erasure) (0) | 2011.11.15 |
In Praise Of Small Code (0) | 2011.11.15 |