diff --git a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java index f53236d..c1be68f 100644 --- a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java +++ b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java @@ -56,7 +56,9 @@ if (!otherAlias.getMethodExecution().isStatic() && otherAlias.getMethodExecution().getCallerMethodExecution() != thisPrevAlias.getMethodExecution()) { // Add a dummy alias to connect disjunct call hierarchies. (thisPrevAlias -> otherAlias) MethodExecution caller = thisPrevAlias.getMethodExecution(); +// MethodExecution callee = new DummyMethodExecution(otherAlias.getMethodExecution()); // Currently does not work because this dummy and the original one will be mixed. MethodExecution callee = otherAlias.getMethodExecution(); + callee.setCaller(caller, caller.getStatements().indexOf(thisPrevAlias.getOccurrencePoint().getStatement())); DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, thisPrevAlias.getOccurrencePoint().getStatement().getThreadNo()); dummyInv.setTimeStamp(callee.getEntryTime()); DummyTracePoint dummyTp = new DummyTracePoint(caller, dummyInv); @@ -82,7 +84,9 @@ if (!otherAlias.getMethodExecution().isStatic() && otherAlias.getMethodExecution().getCallerMethodExecution() != thisPrevAlias.getMethodExecution()) { // Add a dummy alias to connect disjunct call hierarchies. (thisPrevAlias -> otherAlias) MethodExecution caller = thisPrevAlias.getMethodExecution(); +// MethodExecution callee = new DummyMethodExecution(otherAlias.getMethodExecution()); // Currently does not work because this dummy and the original one will be mixed. MethodExecution callee = otherAlias.getMethodExecution(); + callee.setCaller(caller, caller.getStatements().indexOf(thisPrevAlias.getOccurrencePoint().getStatement())); DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, thisPrevAlias.getOccurrencePoint().getStatement().getThreadNo()); dummyInv.setTimeStamp(callee.getEntryTime()); DummyTracePoint dummyTp = new DummyTracePoint(caller, dummyInv); @@ -98,7 +102,9 @@ if (!thisAlias.getMethodExecution().isStatic() && thisAlias.getMethodExecution().getCallerMethodExecution() != otherPrevAlias.getMethodExecution()) { // Add a dummy alias to connect disjunct call hierarchies. (otherPrevAlias -> thisAlias) MethodExecution caller = otherPrevAlias.getMethodExecution(); +// MethodExecution callee = new DummyMethodExecution(thisAlias.getMethodExecution()); // Currently does not work because this dummy and the original one will be mixed. MethodExecution callee = thisAlias.getMethodExecution(); + callee.setCaller(caller, caller.getStatements().indexOf(otherPrevAlias.getOccurrencePoint().getStatement())); DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, otherPrevAlias.getOccurrencePoint().getStatement().getThreadNo()); dummyInv.setTimeStamp(callee.getEntryTime()); DummyTracePoint dummyTp = new DummyTracePoint(caller, dummyInv); @@ -124,7 +130,9 @@ if (!thisAlias.getMethodExecution().isStatic() && thisAlias.getMethodExecution().getCallerMethodExecution() != otherPrevAlias.getMethodExecution()) { // Add a dummy alias to connect disjunct call hierarchies. (otherPrevAlias -> thisAlias) MethodExecution caller = otherPrevAlias.getMethodExecution(); +// MethodExecution callee = new DummyMethodExecution(thisAlias.getMethodExecution()); // Currently does not work because this dummy and the original one will be mixed. MethodExecution callee = thisAlias.getMethodExecution(); + callee.setCaller(caller, caller.getStatements().indexOf(otherPrevAlias.getOccurrencePoint().getStatement())); DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, otherPrevAlias.getOccurrencePoint().getStatement().getThreadNo()); dummyInv.setTimeStamp(callee.getEntryTime()); DummyTracePoint dummyTp = new DummyTracePoint(caller, dummyInv); diff --git a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java index 16f3d4b..ba4c972 100644 --- a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java @@ -295,7 +295,8 @@ */ private List replaceRelatedPoints(List relatedPoints, Map> newToOldMethodExecutionMap) { List replacedRp = new ArrayList<>(relatedPoints); - for (TracePoint rp: replacedRp) { + for (int i = 0; i < replacedRp.size(); i++) { + TracePoint rp = replacedRp.get(i); Statement st = rp.getStatement(); if (st instanceof MethodInvocation) { MethodInvocation methodInv = (MethodInvocation)st; @@ -306,8 +307,15 @@ if (oldMethodExecSet.contains(calledMethodExec)) { methodInv.setCalledMethodExecution(newMethodExec); } + } + } + for (Entry> entry: newToOldMethodExecutionMap.entrySet()) { + MethodExecution newMethodExec = entry.getKey(); + Set oldMethodExecSet = entry.getValue(); + if (oldMethodExecSet.contains(rp.getMethodExecution())) { + DummyTracePoint newTp = new DummyTracePoint(rp, newMethodExec); + replacedRp.set(i, newTp); } - } } return replacedRp; diff --git a/src/org/ntlab/deltaViewer/DeltaAliasCollector.java b/src/org/ntlab/deltaViewer/DeltaAliasCollector.java index d6c6f03..c55a93b 100644 --- a/src/org/ntlab/deltaViewer/DeltaAliasCollector.java +++ b/src/org/ntlab/deltaViewer/DeltaAliasCollector.java @@ -88,8 +88,8 @@ List standardMethodInvocations = collectStandardMethodInvocations(aliasList); List> invocationChains = collectInvocationChains(standardMethodInvocations); aliasList = replaceInvocationChains(aliasList, invocationChains); - aliasList = removeEnclosingInstanceAccessor(aliasList); Map> newToOldMethodExecMap = collectNewToOldMethodExecutionMap(oldAliasList, aliasList); + aliasList = removeEnclosingInstanceAccessor(aliasList, newToOldMethodExecMap); // for debug. System.out.println("standardMethodInvocations: "); @@ -296,10 +296,10 @@ return replacedAliasList; } - private List removeEnclosingInstanceAccessor(List aliasList2) { + private List removeEnclosingInstanceAccessor(List aliasList, Map> newToOldMethodExecMap) { List removedAliasList = new ArrayList<>(aliasList); -// MethodInvocation mi = null; MethodExecution caller = null; + int callerStatement = 0; MethodExecution accessor = null; for (int i = 0; i < removedAliasList.size(); i++) { Alias a = removedAliasList.get(i); @@ -309,28 +309,36 @@ if (Trace.getMethodName(((MethodInvocation) st).getCalledMethodExecution().getSignature()).startsWith("access$")) { caller = a.getMethodExecution(); MethodInvocation mi = ((MethodInvocation) st); - accessor = mi.getCalledMethodExecution(); + callerStatement = mi.getCalledMethodExecution().getCallerStatementExecution(); + accessor = mi.getCalledMethodExecution(); removedAliasList.remove(i); i--; + continue; } } } else if (a.getAliasType() == Alias.AliasType.FORMAL_PARAMETER) { if (Trace.getMethodName(a.getMethodSignature()).startsWith("access$")) { removedAliasList.remove(i); i--; + continue; } } if (a.getMethodExecution() == accessor) { + Statement st = a.getOccurrencePoint().getStatement(); if (a.getAliasType() == Alias.AliasType.ACTUAL_ARGUMENT) { - MethodExecution callee = ((MethodInvocation) a.getOccurrencePoint().getStatement()).getCalledMethodExecution(); - DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, a.getOccurrencePoint().getStatement().getThreadNo()); +// MethodExecution callee = new DummyMethodExecution(((MethodInvocation) st).getCalledMethodExecution()); // Currently does not work because this dummy and the original one will be mixed. + MethodExecution callee = ((MethodInvocation) st).getCalledMethodExecution(); + callee.setCaller(caller, callerStatement); + DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, st.getThreadNo()); dummyInv.setTimeStamp(callee.getEntryTime()); DummyTracePoint dummyTp = new DummyTracePoint(caller, dummyInv); Alias newAlias = new Alias(Alias.AliasType.ACTUAL_ARGUMENT, a.getIndex(), a.getObjectId(), dummyTp); removedAliasList.set(i, newAlias); } else if (a.getAliasType() == Alias.AliasType.RECEIVER) { - MethodExecution callee = ((MethodInvocation) a.getOccurrencePoint().getStatement()).getCalledMethodExecution(); - DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, a.getOccurrencePoint().getStatement().getThreadNo()); +// MethodExecution callee = new DummyMethodExecution(((MethodInvocation) st).getCalledMethodExecution()); // Currently does not work because this dummy and the original one will be mixed. + MethodExecution callee = ((MethodInvocation) st).getCalledMethodExecution(); + callee.setCaller(caller, callerStatement); + DummyMethodInvocation dummyInv = new DummyMethodInvocation(callee, caller.getThisClassName(), caller.getThisObjId(), 0, st.getThreadNo()); dummyInv.setTimeStamp(callee.getEntryTime()); DummyTracePoint dummyTp = new DummyTracePoint(caller, dummyInv); Alias newAlias = new Alias(Alias.AliasType.RECEIVER, a.getIndex(), a.getObjectId(), dummyTp); diff --git a/src/org/ntlab/deltaViewer/DummyTracePoint.java b/src/org/ntlab/deltaViewer/DummyTracePoint.java index 83b27c7..82f6e85 100644 --- a/src/org/ntlab/deltaViewer/DummyTracePoint.java +++ b/src/org/ntlab/deltaViewer/DummyTracePoint.java @@ -5,14 +5,26 @@ import org.ntlab.trace.TracePoint; public class DummyTracePoint extends TracePoint { - private Statement statement = null; + private Statement dummyStatement = null; + private MethodExecution dummyMethodExecution = null; - public DummyTracePoint(MethodExecution methodExecution, Statement statement) { + public DummyTracePoint(MethodExecution methodExecution, Statement dummyStatement) { super(methodExecution, 0); - this.statement = statement; + this.dummyStatement = dummyStatement; + } + + public DummyTracePoint(TracePoint tracePoint, MethodExecution dummyMethodExecution) { + super(tracePoint.getMethodExecution(), tracePoint.getMethodExecution().getStatements().indexOf(tracePoint.getStatement())); + this.dummyMethodExecution = dummyMethodExecution; } public Statement getStatement() { - return statement; + if (dummyStatement == null) return super.getStatement(); + return dummyStatement; + } + + public MethodExecution getMethodExecution() { + if (dummyMethodExecution != null) return dummyMethodExecution; + return super.getMethodExecution(); } } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 0480dd2..c991f1b 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -175,9 +175,13 @@ break; case CONSTRACTOR_INVOCATION: // TODO: Confirm the program behavior when called after RECEIVER. - createObjectVertexOnConstractor(alias); - createMethodExecutionVertex(alias.getObjectId(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); - update(); + if (!objectToVertexMap.containsKey(alias.getObjectId()) || objectToVertexMap.get(alias.getObjectId()).getCell() == null) { + createObjectVertexOnConstractor(alias); + } + if (!methodExecToVertexMap.containsKey(((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution())) { + createMethodExecutionVertex(alias.getObjectId(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); + update(); + } removeMethodExecutionVertex(alias); update(); break; @@ -198,6 +202,10 @@ case RECEIVER: // Make {@code MethodExecutionVertex} of called method execution. MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); + if (calledMethodExec.isConstructor() + && (!objectToVertexMap.containsKey(alias.getObjectId()) || objectToVertexMap.get(alias.getObjectId()).getCell() == null)) { + createObjectVertexOnConstractor(alias); + } if (!methodExecToVertexMap.containsKey(calledMethodExec)) { MethodExecution methodExec = alias.getMethodExecution(); if (!methodExecToVertexMap.containsKey(methodExec)