How to find out the class of the calling function

Hello, is there a way to find out the class name of the calling function, especially for a Java-GWT application?

+6
source share
2 answers

Thread.currentThread not supported in GWT (remember that java code is compiled in javascript), so this is a possible duplicate:

How to recognize caller function in JavaScript?

In GWT, you simply write a jsni wrapper:

 public static native void whosMyCaller() /*-{ $wnd.alert(arguments.callee.caller.toString()); }-*/; 
+4
source

In GWT, this is not real, since in production mode the code is highly optimized by lining and removing unreachable code. For instance. in compiled mode, most functions do not belong to any class, because GWT considered the class definition redundancy. Theoretically, you can find the class of the caller (if you try to analyze the compilation report or through JSNI), but due to optimization of embedding you will get many strange results (for example, even if you work, only a certain class is called, in compiled mode you can find that it is called directly from the onLoad entry point)

0
source

Source: https://habr.com/ru/post/906641/


All Articles