java-callgraph

Rename constructor calls from ClassName -> <init> For better

6/18/2011 10:22:38 AM

Details

diff --git a/src/main/java/gr/gousiosg/javacg/dyn/Instrumenter.java b/src/main/java/gr/gousiosg/javacg/dyn/Instrumenter.java
index 9e9074b..3aee29b 100644
--- a/src/main/java/gr/gousiosg/javacg/dyn/Instrumenter.java
+++ b/src/main/java/gr/gousiosg/javacg/dyn/Instrumenter.java
@@ -164,9 +164,15 @@ public class Instrumenter implements ClassFileTransformer {
 
     private void enhanceMethod(CtBehavior method, String className)
             throws NotFoundException, CannotCompileException {
-        method.insertBefore("gr.gousiosg.javacg.dyn.Graph.push(\"" + className
-                + ":" + method.getName() + "\");");
-        method.insertAfter("gr.gousiosg.javacg.dyn.Graph.pop();");
+        String name = className.substring(className.lastIndexOf('.') + 1, className.length());
+        String methodName = method.getName();
+
+        if (method.getName().equals(name))
+            methodName = "<init>";
+
+        method.insertBefore("gr.gousiosg.javacg.dyn.MethodStack.push(\"" + className
+                + ":" + methodName + "\");");
+        method.insertAfter("gr.gousiosg.javacg.dyn.MethodStack.pop();");
     }
 
     private static void err(String msg) {