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() + "-----");

}

测试:

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

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();

测试:

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

ABAP


CALL FUNCTION 'SYSTEM_CALLSTACK'

      IMPORTING

         callstack = lt_callstack.

测试:

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

要获取更多Jerry的原创技术文章,请关注公众号"汪子熙"或者扫描下面二维码:

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

Java,JavaScript和ABAP通过代码取得当前代码的调用栈Callstack

上一篇:时间段重叠问题,如何用SQL求解?


下一篇:用FFMPEG SDK进行视频转码压缩时解决音视频不同步问题的方法