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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2021-06-13
  • 2022-02-18
  • 2022-01-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-30
  • 2022-02-09
相关资源
相似解决方案