2

Is there any way to know which methods are getting invoked in Java during run time. Actually I am trying to detect those methods which are getting invoked and according to those methods that are invoked use Java Reflection APIS to invoke another method from another classes. In this way I want to divert the execution to my methods first and then call those running methods.

e.g

//Method Invoked_Method = "get the invoked method here "

   if(Invoked_Method.equals("somemethodName"){
   //invoke Another method ..
   }

Although its a security breach, but I am working in team for security products. So have to experiment this.

4

2 回答 2

2

您可能需要考虑 AOP:http ://aopalliance.sourceforge.net/

这允许您拦截与特定表达式匹配的方法调用,并增强或更改该方法的默认行为。

如果您已经在使用它们,那么 Spring 和 Guice 框架提供了相对轻松地利用 AOP 的方法。

于 2013-09-16T23:19:28.540 回答
0

我想您所说的是您需要在运行时跟踪调用堆栈。我找到了一个关于这个的线程。 看一下这个

于 2013-09-16T23:13:58.333 回答