diff --git a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java index 9f22d79..979f5f7 100644 --- a/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java +++ b/src/org/ntlab/deltaViewer/CollaborationAliasCollector.java @@ -7,6 +7,7 @@ import org.ntlab.deltaExtractor.Alias; import org.ntlab.deltaExtractor.IAliasCollector; +import org.ntlab.featureExtractor.Extract; /** * CollaborationAliasCollector is IAliasCollector implementation class to merge aliasList in time stamp order. @@ -37,15 +38,25 @@ /** * Merge other into aliasList(this) in time stamp order. * @param other�@IAliasCollector to be merged into the aliasList. + * @param extract */ - public void merge(IAliasCollector other) { + public void merge(IAliasCollector other, Extract extract) { List otherAliasList = other.getAliasList(); otherAliasList = sortAliasListByTimeStamp(otherAliasList); - int otherIdx = 0; // Index of otherAliasList - int thisIdx = 0; // Index of thisAliasList + int otherIdx = 0; // Index in otherAliasList + int thisIdx = 0; // Index in thisAliasList + int thisOrgIdx = 0; // Index in the original thisAliasList while(otherIdx < otherAliasList.size()) { Alias otherAlias = otherAliasList.get(otherIdx); if (thisIdx >= aliasList.size()) { + if (extract != null && extract.isToConnect() && otherIdx == 0) { + Alias thisPrevAlias = aliasList.get(aliasList.size() - 1); + if (!otherAlias.getMethodExecution().isStatic() && otherAlias.getMethodExecution().getCallerMethodExecution() != thisPrevAlias.getMethodExecution()) { + // Add a dummy alias to connect disjunct call hierarchies. + aliasList.add(new Alias(Alias.AliasType.RECEIVER, 0, otherAlias.getMethodExecution().getThisObjId(), thisPrevAlias.getOccurrencePoint())); + thisIdx++; + } + } aliasList.add(otherAlias); otherIdx++; thisIdx++; continue; @@ -53,16 +64,32 @@ Alias thisAlias = aliasList.get(thisIdx); if (otherAlias.equals(thisAlias)) { - otherIdx++; thisIdx++; + otherIdx++; thisIdx++; thisOrgIdx++; } else { long otherAliasTs = otherAlias.getTimeStamp(); long thisAliasTs = thisAlias.getTimeStamp(); if (otherAliasTs < thisAliasTs) { + if (extract != null && extract.isToConnect() && otherIdx == 0 && thisIdx > 0) { + Alias thisPrevAlias = aliasList.get(thisIdx - 1); + if (!otherAlias.getMethodExecution().isStatic() && otherAlias.getMethodExecution().getCallerMethodExecution() != thisPrevAlias.getMethodExecution()) { + // Add a dummy alias to connect disjunct call hierarchies. + aliasList.add(thisIdx, new Alias(Alias.AliasType.RECEIVER, 0, otherAlias.getMethodExecution().getThisObjId(), thisPrevAlias.getOccurrencePoint())); + thisIdx++; + } + } aliasList.add(thisIdx, otherAlias); otherIdx++; thisIdx++; } else if (otherAliasTs > thisAliasTs) { - thisIdx++; + if (extract != null && extract.isToConnect() && thisOrgIdx == 0 && otherIdx > 0) { + Alias otherPrevAlias = otherAliasList.get(otherIdx - 1); + if (!thisAlias.getMethodExecution().isStatic() && thisAlias.getMethodExecution().getCallerMethodExecution() != otherPrevAlias.getMethodExecution()) { + // Add a dummy alias to connect disjunct call hierarchies. + aliasList.add(thisIdx, new Alias(Alias.AliasType.RECEIVER, 0, thisAlias.getMethodExecution().getThisObjId(), otherPrevAlias.getOccurrencePoint())); + thisIdx++; + } + } + thisIdx++; thisOrgIdx++; } else { if (aliasList.contains(otherAlias)) { otherIdx++; @@ -74,6 +101,14 @@ } } } + if (extract != null && extract.isToConnect() && thisOrgIdx == 0 && otherIdx > 0 && thisIdx < aliasList.size()) { + Alias thisAlias = aliasList.get(thisIdx); + Alias otherPrevAlias = otherAliasList.get(otherIdx - 1); + if (!thisAlias.getMethodExecution().isStatic() && thisAlias.getMethodExecution().getCallerMethodExecution() != otherPrevAlias.getMethodExecution()) { + // Add a dummy alias to connect disjunct call hierarchies. + aliasList.add(thisIdx, new Alias(Alias.AliasType.RECEIVER, 0, thisAlias.getMethodExecution().getThisObjId(), otherPrevAlias.getOccurrencePoint())); + } + } } /** diff --git a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java index adda005..16f3d4b 100644 --- a/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java +++ b/src/org/ntlab/deltaViewer/CollaborationObjectCallGraph.java @@ -106,6 +106,13 @@ thisRoot = tmp; /* lowest common ancestor algorithm */ MethodExecution lca = lowestCommonAncestor(thisRoot, thisStartPoint, otherStartPoint); + if (lca == null) { + if (thisStartPoint.getEntryTime() < otherStartPoint.getEntryTime()) { + lca = thisStartPoint; + } else { + lca = otherStartPoint; + } + } startPoints.clear(); startPoints.add(lca); @@ -136,7 +143,7 @@ if (pRoots.contains(qTmp)) return qTmp; qTmp = qTmp.getParent(); } - return root; + return qTmp; } /** diff --git a/src/org/ntlab/deltaViewer/MagnetRONFrame.java b/src/org/ntlab/deltaViewer/MagnetRONFrame.java index fa86c7f..3601a8f 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONFrame.java +++ b/src/org/ntlab/deltaViewer/MagnetRONFrame.java @@ -213,7 +213,7 @@ if (cac == null) { cac = new CollaborationAliasCollector(dac); } else { - cac.merge(dac); + cac.merge(dac, extract); } } cocg.shrinkAll(newToOldMethodExecMap); @@ -255,7 +255,7 @@ if (cac == null) { cac = new CollaborationAliasCollector(dac); } else { - cac.merge(dac); + cac.merge(dac, null); } } cocg.shrinkAll(newToOldMethodExecMap); diff --git a/src/org/ntlab/featureExtractor/Extract.java b/src/org/ntlab/featureExtractor/Extract.java index b74bff0..8c10c25 100644 --- a/src/org/ntlab/featureExtractor/Extract.java +++ b/src/org/ntlab/featureExtractor/Extract.java @@ -16,13 +16,16 @@ private int order = 0; - public Extract(String srcId, String srcClass, String dstId, String dstClass, String type, int order) { + private boolean toConnect = false; + + public Extract(String srcId, String srcClass, String dstId, String dstClass, String type, int order, boolean toConnect) { this.srcId = srcId; this.srcClass = srcClass; this.dstId = dstId; this.dstClass = dstClass; this.type = type; this.order = order; + this.toConnect = toConnect; } public String getSrcId() { @@ -49,4 +52,7 @@ return order; } + public boolean isToConnect() { + return toConnect; + } } diff --git a/src/org/ntlab/featureExtractor/MagnetronParser.java b/src/org/ntlab/featureExtractor/MagnetronParser.java index 14e284e..43bee98 100644 --- a/src/org/ntlab/featureExtractor/MagnetronParser.java +++ b/src/org/ntlab/featureExtractor/MagnetronParser.java @@ -125,13 +125,17 @@ Map srcObject = (Map) object.get("src"); Map dstObject = (Map) object.get("dst"); int order = Integer.parseInt((String) object.get("order")); + boolean isToConnect = false; + if (object.get("connect") != null) { + isToConnect = (Boolean) object.get("connect"); + } Extract extract = new Extract( (String) srcObject.get("id"), (String) srcObject.get("class"), (String) dstObject.get("id"), (String) dstObject.get("class"), (String) object.get("type"), - order); + order, isToConnect); extracts.add(extract); return residual; } @@ -194,6 +198,12 @@ } else if (line.startsWith("null")) { residual = line.substring(4); values[0] = null; + } else if (line.startsWith("true")) { + residual = line.substring(4); + values[0] = true; + } else if (line.startsWith("false")) { + residual = line.substring(5); + values[0] = false; } else { // To Do } diff --git a/src/tests/CollaborationAliasCollectorTest.java b/src/tests/CollaborationAliasCollectorTest.java index c0d52cf..f1eb166 100644 --- a/src/tests/CollaborationAliasCollectorTest.java +++ b/src/tests/CollaborationAliasCollectorTest.java @@ -30,7 +30,7 @@ if (cac == null) { cac = new CollaborationAliasCollector(dac); } else { - cac.merge(dac); + cac.merge(dac, null); } } System.out.println("mergedAliasList: "); diff --git a/src/tests/CollaborationObjectCallGraphTest.java b/src/tests/CollaborationObjectCallGraphTest.java index 3ed9123..d6a8454 100644 --- a/src/tests/CollaborationObjectCallGraphTest.java +++ b/src/tests/CollaborationObjectCallGraphTest.java @@ -46,7 +46,7 @@ if (cac == null) { cac = new CollaborationAliasCollector(dac); } else { - cac.merge(dac); + cac.merge(dac, null); } } } diff --git a/src/tests/MagnetRONFrameTest.java b/src/tests/MagnetRONFrameTest.java index 700ec10..4e92d54 100644 --- a/src/tests/MagnetRONFrameTest.java +++ b/src/tests/MagnetRONFrameTest.java @@ -85,7 +85,7 @@ if (cac == null) { cac = new CollaborationAliasCollector(dac); } else { - cac.merge(dac); + cac.merge(dac, null); } } // new Thread() { diff --git a/traces/EclipseDebug.magnet b/traces/EclipseDebug.magnet index dff8124..7200715 100644 --- a/traces/EclipseDebug.magnet +++ b/traces/EclipseDebug.magnet @@ -7,6 +7,18 @@ "extracts": [ { "src": { + "class": "public void org.eclipse.jdt.internal.debug.core.EventDispatcher.run(", + "id": "629542817" + }, + "dst": { + "class": "org.eclipse.jdi.internal.event.EventSetImpl", + "id": "1400795012" + }, + "type": "This-Another", + "order": "0" + }, + { + "src": { "class": "public boolean org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.handleBreakpointEvent(", "id": "666051245" }, @@ -15,7 +27,8 @@ "id": "907205473" }, "type": "This-Another", - "order": "0" + "order": "0", + "connect": true }, { "src": { @@ -41,18 +54,6 @@ "type": "Container-Component(Collection)", "order": "0" }, - { - "src": { - "class": "public void org.eclipse.jdt.internal.debug.core.EventDispatcher.run(", - "id": "629542817" - }, - "dst": { - "class": "org.eclipse.jdi.internal.event.EventSetImpl", - "id": "1400795012" - }, - "type": "This-Another", - "order": "0" - }, { "src": { "class": "public com.sun.jdi.event.EventSet org.eclipse.jdi.internal.event.EventQueueImpl.remove(",