Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack
Java
StackTraceElement stack[] = Thread.currentThread().getStackTrace(); System.out.println("Callstack test"); for(int i = 0; i < stack.length; i++){ System.out.println("Jerry:" + stack[i].getClassName() + ":" + stack[i].getMethodName() + "-----"); }
测试:
JavaScript
function getCallStack() { var stack = "Callstack:", fn =arguments.callee; while ( (fn = fn.caller) ) { stack = stack + "\n" +fn.name; } return stack; } function test1() { console.log(getCallStack()); } function test2() { test1(); } function test3() { test2(); } function test4() { test3(); } test4();
测试:
ABAP
CALL FUNCTION 'SYSTEM_CALLSTACK' IMPORTING callstack = lt_callstack.
测试:
要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:
相关推荐
匆匆那些年 2020-10-15
Cocolada 2020-11-12
82550698 2020-11-09
mnm0 2020-11-08
gaobudong 2020-11-04
wangdianyong 2020-07-23
webpackvuees 2020-07-23
锋锋 2020-07-14
xlb 2020-07-12
liuttorrie 2020-07-04
XiaoMuFireAnt 2020-06-18
kekeromer 2020-05-07
数据齿轮 2020-03-03
Lophole 2020-03-03
YukiRain 2020-03-01
liuyang000 2020-01-06
zhegechengxuyuan 2019-11-16
woxmh 2019-11-09
bloomrose 2019-11-08