diff --git a/lib/jgraphx-3.9.8.1-sources.jar b/lib/jgraphx-3.9.8.1-sources.jar new file mode 100644 index 0000000..593a146 --- /dev/null +++ b/lib/jgraphx-3.9.8.1-sources.jar Binary files differ diff --git a/src/org/ntlab/deltaExtractor/Alias.java b/src/org/ntlab/deltaExtractor/Alias.java index 5477266..e3cd69f 100644 --- a/src/org/ntlab/deltaExtractor/Alias.java +++ b/src/org/ntlab/deltaExtractor/Alias.java @@ -73,4 +73,41 @@ } } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((aliasType == null) ? 0 : aliasType.hashCode()); + result = prime * result + index; + result = prime * result + ((objectId == null) ? 0 : objectId.hashCode()); + result = prime * result + ((occurrencePoint == null) ? 0 : occurrencePoint.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Alias other = (Alias) obj; + if (aliasType != other.aliasType) + return false; + if (index != other.index) + return false; + if (objectId == null) { + if (other.objectId != null) + return false; + } else if (!objectId.equals(other.objectId)) + return false; + if (occurrencePoint == null) { + if (other.occurrencePoint != null) + return false; + } else if (!occurrencePoint.equals(other.occurrencePoint)) + return false; + return true; + } + } \ No newline at end of file diff --git a/src/org/ntlab/deltaExtractor/AliasPair.java b/src/org/ntlab/deltaExtractor/AliasPair.java new file mode 100644 index 0000000..b937f55 --- /dev/null +++ b/src/org/ntlab/deltaExtractor/AliasPair.java @@ -0,0 +1,29 @@ +package org.ntlab.deltaExtractor; + +import java.util.AbstractMap.SimpleEntry; + +public class AliasPair { + private SimpleEntry aliasPair; + private boolean isSrcSideChanged; + + public AliasPair(boolean isSrcSideChanged) { + this.isSrcSideChanged = isSrcSideChanged; + } + + public AliasPair(Alias fromAlias, Alias toAlias, boolean isSrcSideChanged) { + this(isSrcSideChanged); + this.aliasPair = new SimpleEntry<>(fromAlias, toAlias); + } + + public SimpleEntry setAliasPair(Alias fromAlias, Alias toAlias) { + return this.aliasPair = new SimpleEntry<>(fromAlias, toAlias); + } + + public SimpleEntry getAliasPair() { + return this.aliasPair; + } + + public boolean getIsSrcSideChanged() { + return this.isSrcSideChanged; + } +} \ No newline at end of file diff --git a/src/org/ntlab/deltaExtractor/ObjectIdPair.java b/src/org/ntlab/deltaExtractor/ObjectIdPair.java deleted file mode 100644 index b9bc5ae..0000000 --- a/src/org/ntlab/deltaExtractor/ObjectIdPair.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.ntlab.deltaExtractor; - -import java.util.AbstractMap.SimpleEntry; - -public class ObjectIdPair { - private SimpleEntry objIdPair; - private boolean isSrcSideChanged; - - public ObjectIdPair(String fromObjId, String toObjId, boolean isSrcSideChanged) { - this.objIdPair = new SimpleEntry<>(fromObjId, toObjId); - this.isSrcSideChanged = isSrcSideChanged; - } - - public SimpleEntry getObjIdPair() { - return this.objIdPair; - } - - public boolean getIsSrcSideChanged() { - return this.isSrcSideChanged; - } -} \ No newline at end of file diff --git a/src/org/ntlab/deltaViewer/DeltaAliasCollector.java b/src/org/ntlab/deltaViewer/DeltaAliasCollector.java index 9f4f44f..03c5047 100644 --- a/src/org/ntlab/deltaViewer/DeltaAliasCollector.java +++ b/src/org/ntlab/deltaViewer/DeltaAliasCollector.java @@ -8,7 +8,7 @@ import org.ntlab.deltaExtractor.Alias; import org.ntlab.deltaExtractor.IAliasCollector; -import org.ntlab.deltaExtractor.ObjectIdPair; +import org.ntlab.deltaExtractor.AliasPair; import org.ntlab.trace.MethodExecution; import org.ntlab.trace.MethodInvocation; @@ -22,9 +22,10 @@ private String srcObjId; private String dstObjId; private List aliasList = new ArrayList<>(); - private Map aliasToObjIdPairMap = new HashMap<>(); + private List aliasPairList = new ArrayList<>(); - private Alias curAlias; + private Alias curAlias = null; + private AliasPair curAliasPair = null; public DeltaAliasCollector() { } @@ -77,13 +78,19 @@ default: break; } + if (curAliasPair != null) { + curAliasPair.setAliasPair(alias, curAlias); + aliasPairList.add(curAliasPair); + curAliasPair = null; + } curAlias = alias; System.out.println(alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo() + " : " + alias.getAliasType().toString()); } @Override + // from�̕����ߋ� public void changeTrackingObject(String fromObjId, String toObjId, boolean isSrcSideChanged) { - aliasToObjIdPairMap.put(curAlias, new ObjectIdPair(toObjId, fromObjId, isSrcSideChanged)); + curAliasPair = new AliasPair(isSrcSideChanged); System.out.println(fromObjId + " -> " + toObjId + " " + isSrcSideChanged); } @@ -91,11 +98,28 @@ return this.aliasList; } - public Map getAliasToObjectPair() { - return aliasToObjIdPairMap; + public List getAliasPairList() { + return aliasPairList; } - public ObjectIdPair getObjectPairByAlias(Alias alias) { - return aliasToObjIdPairMap.get(alias); + public List getAliasPairListByAlias(Alias toAlias) { + List aliasPairListByAlias = new ArrayList<>(); + for(AliasPair ap: aliasPairList) { + if(ap.getAliasPair().getValue().equals(toAlias)) { + aliasPairListByAlias.add(ap); + } + } + return aliasPairListByAlias; } + + public List getAliasPairListByAliasPair(Alias fromAlias, Alias toAlias) { + List aliasPairListByAlias = new ArrayList<>(); + for(AliasPair ap: aliasPairList) { + if(ap.getAliasPair().getKey().equals(fromAlias) && ap.getAliasPair().getValue().equals(toAlias)) { + aliasPairListByAlias.add(ap); + } + } + return aliasPairListByAlias; + } + } diff --git a/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java b/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java index 17c9faf..86046c3 100644 --- a/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java +++ b/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java @@ -1,5 +1,9 @@ package org.ntlab.deltaViewer; +import java.util.AbstractMap.SimpleEntry; +import java.util.HashMap; +import java.util.Map.Entry; + import org.jgrapht.Graph; import org.jgrapht.ext.JGraphXAdapter; import org.jgrapht.graph.DefaultEdge; @@ -28,7 +32,7 @@ * * @param vertex Vertex to be added to the graph. */ - private mxICell addJGraphTVertex(Object vertex) { + private mxICell addJGraphTVertex(String id, Object vertex) { getModel().beginUpdate(); try { @@ -40,7 +44,15 @@ // Save reference between vertex and cell. getVertexToCellMap().put(vertex, cell); - getCellToVertexMap().put(cell, vertex); + getCellToVertexMap().put(cell, vertex); +// for(Entry e: getVertexToCellMap().entrySet()) { +// System.out.println("addJGraphTVertex: " + e.getKey() + ", " + e.getValue()); +// } +// System.out.println(); +// for(Entry e: getCellToVertexMap().entrySet()) { +// System.out.println("addJGraphTVertex: " + e.getKey() + ", " + e.getValue()); +// } + return cell; } finally { getModel().endUpdate(); @@ -52,18 +64,18 @@ * * @param edge Edge to be added to the graph. Source and target vertices are needed. */ - private mxICell addJGraphTEdge(Object sourceVertex, Object targetVertex, Object edge) { + private mxICell addJGraphTEdge(Object sourceCell, Object targetCell, Object edge) { getModel().beginUpdate(); try { // if the one of the vertices is not drawn, don't draw the edge - if (!(getVertexToCellMap().containsKey(sourceVertex) && getVertexToCellMap().containsKey(targetVertex))) { - return null; - } +// if (!(getVertexToCellMap().containsKey(sourceVertex) && getVertexToCellMap().containsKey(targetVertex))) { +// return null; +// } // get mxICells - Object sourceCell = getVertexToCellMap().get(sourceVertex); - Object targetCell = getVertexToCellMap().get(targetVertex); +// Object sourceCell = getVertexToCellMap().get(sourceVertex); +// Object targetCell = getVertexToCellMap().get(targetVertex); // add edge between mxICells mxICell cell = (mxICell) super.insertEdge(defaultParent, null, edge, sourceCell, targetCell); @@ -89,17 +101,17 @@ * @param target * @return */ - public Object insertDeltaEdge(Object parent, String id, Object value, Object source, Object target) { + public Object insertDeltaEdge(Object parent, String id, Object value, Object sourceCell, Object targetCell) { // find vertices of edge - Object sourceVertex = getCellToVertexMap().get(source); - Object targetVertex = getCellToVertexMap().get(target); + Object sourceVertex = getCellToVertexMap().get(sourceCell); + Object targetVertex = getCellToVertexMap().get(targetCell); if (value == null) { graphT.addEdge(sourceVertex, targetVertex); } else { graphT.addEdge(sourceVertex, targetVertex, value); } - mxICell cellEdge = addJGraphTEdge(sourceVertex, targetVertex, value); + mxICell cellEdge = addJGraphTEdge(sourceCell, targetCell, value); cellEdge.setId(id); return cellEdge; } @@ -127,8 +139,10 @@ * @return */ public Object insertDeltaVertex(Object parent, String id, Object value, double x, double y, double width, double height, String style) { +// graphT.addVertex(value); +// mxICell cell = addJGraphTVertex(value); graphT.addVertex(value); - mxICell cell = addJGraphTVertex(value); + mxICell cell = addJGraphTVertex(id, value); cell.setId(id); ((mxCell) parent).insert(cell); diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 53a3ed9..c2decd4 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -22,7 +22,7 @@ import org.ntlab.deltaExtractor.Alias; import org.ntlab.deltaExtractor.Delta; import org.ntlab.deltaExtractor.ExtractedStructure; -import org.ntlab.deltaExtractor.ObjectIdPair; +import org.ntlab.deltaExtractor.AliasPair; import org.ntlab.deltaViewer.Edge.TypeName; import org.ntlab.deltaExtractor.Alias.AliasType; import org.ntlab.trace.ArrayAccess; @@ -92,7 +92,7 @@ this(); this.eStructure = extractedStructure; this.deltaAliasCollector = deltaAliasCollector; - // init(); +// init(); } /** Initialize JFrame, make vertex object and edge object. */ @@ -110,7 +110,7 @@ frame.setVisible(true); createObjectVertices(eStructure); - createEdgeToObject(deltaAliasCollector.getAliasList(), deltaAliasCollector.getAliasToObjectPair()); + createEdgeToObject(deltaAliasCollector.getAliasList(), deltaAliasCollector.getAliasPairList()); // Fit graph size in visible JFrame. mxGraphView view = mxgraphComponent.getGraph().getView(); @@ -122,6 +122,7 @@ } scale = (double)componentWidth/viewWidth; System.out.println(", " + scale); +// scale = 1.5; view.setScale(scale); deltaAnimation.setScale(scale); @@ -232,50 +233,51 @@ mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_TOP, alignTopVertex.toArray(new Object[alignTopVertex.size()])); mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_TOPTOBOTTOM, edgeObject.toArray(new Object[edgeObject.size()])); mxgraph.setCellStyleFlags(mxConstants.STYLE_DASHED, 1, true, edgeObjectCreate.toArray(new Object[edgeObjectCreate.size()])); - // mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ENTITY_RELATION, edgeObject.toArray(new Object[edgeObject.size()])); - // mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL, edgeObject.toArray(new Object[edgeObject.size()])); +// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ENTITY_RELATION, edgeObject.toArray(new Object[edgeObject.size()])); +// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL, edgeObject.toArray(new Object[edgeObject.size()])); mxgraph.setCellStyleFlags(mxConstants.STYLE_ROUNDED, 1, true, roundEdge.toArray(new Object[roundEdge.size()])); mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_TOP, roundEdge.toArray(new Object[roundEdge.size()])); mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_BOTTOM, roundEdge.toArray(new Object[roundEdge.size()])); - // mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.SHAPE_CURVE, edgeObject.toArray(new Object[edgeObject.size()])); +// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.SHAPE_CURVE, edgeObject.toArray(new Object[edgeObject.size()])); mxgraph.setCellStyles(mxConstants.STYLE_STROKECOLOR, "#008000", edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); mxgraph.setCellStyleFlags(mxConstants.STYLE_DASHED, 1, true, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); - // mxgraph.setCellStyleFlags(mxConstants.STYLE_AUTOSIZE, 1, true, vertexObject.toArray(new Object[vertexObject.size()])); - // mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); - // mxgraph.setCellStyles(mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); +// mxgraph.setCellStyleFlags(mxConstants.STYLE_AUTOSIZE, 1, true, vertexObject.toArray(new Object[vertexObject.size()])); +// mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.EDGESTYLE_ORTHOGONAL, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); +// mxgraph.setCellStyles(mxConstants.STYLE_ELBOW, mxConstants.ELBOW_VERTICAL, edgeMethodExec.toArray(new Object[edgeMethodExec.size()])); } - // private double getXForCell(String id) { - // double res = -1; - // if (objectToVertexMap.containsKey(id)) { - // Object cell = objectToVertexMap.get(id).getCell(); - // res = mxgraph.getCellGeometry(cell).getX(); - // } - // return res; - // } +// private double getXForCell(String id) { +// double res = -1; +// if (objectToVertexMap.containsKey(id)) { +// Object cell = objectToVertexMap.get(id).getCell(); +// res = mxgraph.getCellGeometry(cell).getX(); +// } +// return res; +// } - // private double getYForCell(String id) { - // double res = -1; - // if (objectToVertexMap.containsKey(id)) { - // Object cell = objectToVertexMap.get(id).getCell(); - // res = mxgraph.getCellGeometry(cell).getY(); - // } - // return res; - // } +// private double getYForCell(String id) { +// double res = -1; +// if (objectToVertexMap.containsKey(id)) { +// Object cell = objectToVertexMap.get(id).getCell(); +// res = mxgraph.getCellGeometry(cell).getY(); +// } +// return res; +// } - // private mxICell getRootParentCell(Object object) { - // mxICell cell = (mxICell) object; - // if(cell.getParent().getValue() == null) { - // return cell; - // } - // return getRootParentCell(cell.getParent()); - // } +// private mxICell getRootParentCell(Object object) { +// mxICell cell = (mxICell) object; +// if(cell.getParent().getValue() == null) { +// return cell; +// } +// return getRootParentCell(cell.getParent()); +// } private Point getAbsolutePointforCell(mxICell cell) { Point p1 = cell.getGeometry().getPoint(); - if(cell.getParent().getValue() == null) { + if(cell.getParent().getValue() == null || cell.equals(cell.getParent())) { return p1; } + System.out.println(cell.getId() + ", " + cell.getParent().getId()); Point p2 = getAbsolutePointforCell(cell.getParent()); return new Point((int) (p1.getX() + p2.getX()), (int) (p1.getY() + p2.getY())); } @@ -487,7 +489,7 @@ if (srcClassName.contains("[L")) { srcClassName = formatArrayName(srcClassName); } - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getSrcClassName(), srcClassName, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getSrcObjectId(), srcClassName, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. objectToVertexMap.put(ref.getSrcObjectId(), new ObjectVertex(ref.getSrcClassName(), vertex, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)))); } if (!objectToVertexMap.containsKey(ref.getDstObjectId())) { @@ -496,7 +498,7 @@ if (dstClassName.contains("[L")) { dstClassName = formatArrayName(dstClassName); } - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstClassName(), dstClassName, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstObjectId(), dstClassName, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. objectToVertexMap.put(ref.getDstObjectId(), new ObjectVertex(ref.getDstClassName(), vertex, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)))); } } else { @@ -516,7 +518,7 @@ if (srcClassName.contains("[L")) { srcClassName = formatArrayName(srcClassName); } - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getSrcClassName(), srcClassName, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getSrcObjectId(), srcClassName, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. objectToVertexMap.put(ref.getSrcObjectId(), new ObjectVertex(ref.getSrcClassName(), vertex, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)))); cnt++; } @@ -525,7 +527,7 @@ if (dstClassName.contains("[L")) { dstClassName = formatArrayName(dstClassName); } - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstClassName(), dstClassName, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstObjectId(), dstClassName, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. objectToVertexMap.put(ref.getDstObjectId(), new ObjectVertex(ref.getDstClassName(), vertex, xCor - (time * (dstSideSize - i + cnt)), yCor + (time * (dstSideSize - i + cnt)))); } } else { @@ -551,8 +553,12 @@ double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); MethodInvocation methodInvocation = (MethodInvocation)alias.getOccurrencePoint().getStatement(); String fieldName = methodInvocation.getCallerSideMethodName(); - ObjectIdPair objIdPair = deltaAliasCollector.getObjectPairByAlias(alias); - boolean isSrcSideChanged = objIdPair.getIsSrcSideChanged(); + List aliasPairListByAlias = deltaAliasCollector.getAliasPairListByAlias(alias); + AliasPair aliasPair = null; + if (aliasPairListByAlias.size() >= 1) { + aliasPair = aliasPairListByAlias.get(0); + } + boolean isSrcSideChanged = aliasPair.getIsSrcSideChanged(); mxgraph.getModel().beginUpdate(); try { Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, vertexObj.getLabel(), vertexObj.getLabel(), sourceCell.getGeometry().getX() + overlapWidth, sourceCell.getGeometry().getY() + overlapHeight, VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. @@ -677,6 +683,8 @@ sourceCell.setParent(targetCell.getParent()); targetCell.getParent().insert(sourceCell); + System.out.println("moveLocalObjectVertex: " + sourceCell.getId() + ", " + sourceCell.getParent().getId()); + System.out.println(" " + targetCell.getId() + ", " + targetCell.getParent().getId()); Point absolutePointTargetCell = getAbsolutePointforCell(sourceCell.getParent()); sourceCell.getGeometry().setX(sourceX - absolutePointTargetCell.getX()); @@ -861,7 +869,7 @@ // } // } // } - + /** Update ObjectVertices size and position. */ private void updateObjectVertices() { // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology @@ -869,31 +877,33 @@ try { for (ObjectVertex objectVertex: objectToVertexMap.values()) { mxCell objectVertexCell = ((mxCell) objectVertex.getCell()); - int time = objectVertexCell.getChildCount(); - if (time == 0) { - time = 1; - } - if(objectVertexCell.getGeometry().getWidth() != VERTEX_OBJECT_SIZE.getWidth() * time) { - System.out.println("updateVertexObjectSize: " + objectVertexCell.getGeometry().getWidth() + "->" + VERTEX_OBJECT_SIZE.getWidth() * time+ ", " + objectVertexCell.getId()); - Dimension targetDimension = new Dimension(); - targetDimension.setSize(VERTEX_OBJECT_SIZE.getWidth() * time, VERTEX_OBJECT_SIZE.getHeight() * time); - if (objectVertexCell.getParent() != mxDefaultParent && (objectVertexCell.getChildCount() != 0 || objectVertexCell.getGeometry().getWidth() > VERTEX_OBJECT_SIZE.getWidth() * time)) { - double overlapX = (targetDimension.getWidth() - objectVertexCell.getGeometry().getWidth()) / 2 / Math.sqrt(2); - double overlapY = (targetDimension.getHeight() - objectVertexCell.getGeometry().getHeight()) / 2 / Math.sqrt(2); - System.out.println("updateVertexObjectPosition: " + objectVertexCell.getGeometry().getX() + " - " + overlapX); - mxPoint targetPoint = new mxPoint(objectVertexCell.getGeometry().getX() - overlapX, objectVertexCell.getGeometry().getY() + overlapY); - for (MethodExecutionVertex methodExecVertex: methodExecToVertexMap.values()) { - List arguments = methodExecVertex.getArguments(); - if (arguments != null && arguments.contains(objectVertex)) { - targetPoint.setY(objectVertexCell.getGeometry().getY() - overlapY); - break; - } - } - deltaAnimation.setVertexAnimation(objectVertexCell, targetPoint); - deltaAnimation.startVertexAnimation(); + if (objectVertexCell != null) { + int time = objectVertexCell.getChildCount(); + if (time == 0) { + time = 1; } - deltaAnimation.setResizeVertexAnimation(objectVertexCell, targetDimension); - deltaAnimation.startResizeVertexAnimation(); + if(objectVertexCell.getGeometry().getWidth() != VERTEX_OBJECT_SIZE.getWidth() * time) { + System.out.println("updateVertexObjectSize: " + objectVertexCell.getGeometry().getWidth() + "->" + VERTEX_OBJECT_SIZE.getWidth() * time+ ", " + objectVertexCell.getId()); + Dimension targetDimension = new Dimension(); + targetDimension.setSize(VERTEX_OBJECT_SIZE.getWidth() * time, VERTEX_OBJECT_SIZE.getHeight() * time); + if (objectVertexCell.getParent() != mxDefaultParent && (objectVertexCell.getChildCount() != 0 || objectVertexCell.getGeometry().getWidth() > VERTEX_OBJECT_SIZE.getWidth() * time)) { + double overlapX = (targetDimension.getWidth() - objectVertexCell.getGeometry().getWidth()) / 2 / Math.sqrt(2); + double overlapY = (targetDimension.getHeight() - objectVertexCell.getGeometry().getHeight()) / 2 / Math.sqrt(2); + System.out.println("updateVertexObjectPosition: " + objectVertexCell.getGeometry().getX() + " - " + overlapX); + mxPoint targetPoint = new mxPoint(objectVertexCell.getGeometry().getX() - overlapX, objectVertexCell.getGeometry().getY() + overlapY); + for (MethodExecutionVertex methodExecVertex: methodExecToVertexMap.values()) { + List arguments = methodExecVertex.getArguments(); + if (arguments != null && arguments.contains(objectVertex)) { + targetPoint.setY(objectVertexCell.getGeometry().getY() - overlapY); + break; + } + } + deltaAnimation.setVertexAnimation(objectVertexCell, targetPoint); + deltaAnimation.startVertexAnimation(); + } + deltaAnimation.setResizeVertexAnimation(objectVertexCell, targetDimension); + deltaAnimation.startResizeVertexAnimation(); + } } } } finally { @@ -1099,7 +1109,7 @@ /** Make edge object in JGraphT and draw this in JGraphX. * @param map * @param collection */ - private void createEdgeToObject(List aliasList, Map aliasToObjIdPair) { + private void createEdgeToObject(List aliasList, List aliasPairList) { for (int i = 0; i < aliasList.size()-1; i++) { Alias curAlias = aliasList.get(i); Alias nextAlias = aliasList.get(i+1); @@ -1135,16 +1145,21 @@ System.out.println("ARRAY " + srcClassName + "(" + curAlias.getObjectId() + ") -> " + "(" + nextAlias.getObjectId() + "), " + fieldName); } } - if (srcClassName != null && fieldName != null && srcClassName != null) { + if (srcClassName != null && fieldName != null && srcClassName != null && !edgeMap.containsKey(srcClassName + "." + fieldName)) { // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); try { - ObjectIdPair objIdPair = aliasToObjIdPair.get(nextAlias); - String srcObjId = objIdPair.getObjIdPair().getKey(); - String dstObjId = objIdPair.getObjIdPair().getValue(); - boolean isSrcSideChanged = objIdPair.getIsSrcSideChanged(); + List aliasPairListByAlias = deltaAliasCollector.getAliasPairListByAliasPair(curAlias, nextAlias); + AliasPair aliasPair = null; + if (aliasPairListByAlias.size() >= 1) { + aliasPair = aliasPairListByAlias.get(0); + } + String srcObjId = aliasPair.getAliasPair().getKey().getObjectId(); + String dstObjId = aliasPair.getAliasPair().getValue().getObjectId(); + boolean isSrcSideChanged = aliasPair.getIsSrcSideChanged(); // String dstClassName = curAlias.getMethodExecution().getThisClassName(); - System.out.println("makeEdgeObject: " + fieldName + ", " + srcClassName/* + ", " + dstClassName*/); + System.out.println("makeEdgeObject: " + fieldName + ", " + srcClassName + " (" + objectToVertexMap.get(srcObjId).getCell().hashCode() + "), " + " (" + objectToVertexMap.get(dstObjId).getCell().hashCode() + ")"/* + ", " + dstClassName*/); + // BUG:NullPointerException Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, fieldName, objectToVertexMap.get(srcObjId).getCell(), objectToVertexMap.get(dstObjId).getCell()); if(isSrcSideChanged) { ((mxCell)edge).setStyle("exitX=1;exitY=1;exitPerimeter=1;entryX=0;entryY=0;entryPerimeter=1;"); @@ -1248,14 +1263,20 @@ private void outputLog() { for (Object object: mxgraph.getChildCells(mxDefaultParent)) { - System.out.println(object); + System.out.println(object + " " + object.hashCode()); for (int i = 0; i < ((mxICell)object).getChildCount(); i++) { - System.out.println(" " + ((mxICell)object).getChildAt(i)); + System.out.println(" " + ((mxICell)object).getChildAt(i) + " " + object.hashCode()); } } System.out.println("\nObject"); - for (ObjectVertex vo: objectToVertexMap.values()) { - System.out.println(vo.getLabel()); + for (Entry e: objectToVertexMap.entrySet()) { + String objId = e.getKey(); + ObjectVertex vo = e.getValue(); + if (vo.getCell() != null) { + System.out.println(vo.getLabel() + " (" + objId + ")" + " " + vo.getCell().hashCode()); + } else { + System.out.println(vo.getLabel() + " (" + objId + ")"); + } for (MethodExecutionVertex vme: vo.getVertexMethodExecutions()) { System.out.println(" " + vme.getLabel()); for (ObjectVertex vmevo: vme.getArguments()) { diff --git a/src/org/ntlab/deltaViewer/DeltaViewerSample.java b/src/org/ntlab/deltaViewer/DeltaViewerSample.java index 4fcf9a1..4e5370b 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewerSample.java +++ b/src/org/ntlab/deltaViewer/DeltaViewerSample.java @@ -4,15 +4,20 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import org.ntlab.deltaExtractor.Alias; import org.ntlab.deltaExtractor.DeltaExtractorJSON; import org.ntlab.deltaExtractor.ExtractedStructure; import org.ntlab.trace.FieldAccess; +import org.ntlab.trace.FieldUpdate; +import org.ntlab.trace.IStatementVisitor; import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.MethodInvocation; import org.ntlab.trace.Reference; import org.ntlab.trace.Statement; import org.ntlab.trace.ThreadInstance; +import org.ntlab.trace.Trace; import org.ntlab.trace.TraceJSON; import org.ntlab.trace.TracePoint; @@ -27,17 +32,10 @@ * @param args */ public static void main(String[] args) { -// TraceJSON trace = new TraceJSON("traces/_worstCase.txt"); // TraceJSON trace = new TraceJSON("traces/jEditBenchmark.trace"); // TraceJSON trace = new TraceJSON("traces/jHotDrawBenchmark.trace"); // TraceJSON trace = new TraceJSON("traces/ArgoUMLBenchmark.trace"); -// Trace trace = new Trace("traces\\worstCase.txt"); -// Trace trace = new TraceJSON("traces\\_worstCase.txt"); - - // Change! // TraceJSON trace = new TraceJSON("traces/testTrace2.txt"); -// TraceJSON trace = new TraceJSON("traces/_worstCase.txt"); -// DeltaExtractorJSON dex = new DeltaExtractorJSON(trace); // one delta extract // TraceJSON trace = new TraceJSON("traces/traceSample1.txt"); @@ -46,28 +44,78 @@ // TraceJSON trace = new TraceJSON("traces/_worstCase.txt"); // TraceJSON trace = new TraceJSON("traces/sample1.trace"); // TraceJSON trace = new TraceJSON("traces/sampleArray.trace"); - TraceJSON trace = new TraceJSON("traces/sampleCollection.trace"); +// TraceJSON trace = new TraceJSON("traces/sampleCollection.trace"); // TraceJSON trace = new TraceJSON("traces/sampleCreate.trace"); // TraceJSON trace = new TraceJSON("traces/sampleStatic.trace"); - - // Error display MagnetRON. +// TraceJSON trace = new TraceJSON("traces/jHotDrawBenchmarkWithMoreStandardClasses.trace"); +// TraceJSON trace = new TraceJSON("traces/ArgoUMLBenchmarkWithMoreStandardClasses.trace"); // TraceJSON trace = new TraceJSON("traces/testTrace3.txt"); // TraceJSON trace = new TraceJSON("traces/testTrace5.txt"); - DeltaExtractorJSON s = new DeltaExtractorJSON(trace); - HashMap threads = trace.getAllThreads(); - ThreadInstance thread = threads.values().iterator().next(); // �Ō�̃X���b�h�����Ă��邾���c - TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); - DeltaAliasCollector dac = new DeltaAliasCollector(); + +// DeltaExtractorJSON dex = new DeltaExtractorJSON(trace); +// HashMap threads = trace.getAllThreads(); +// ThreadInstance thread = threads.values().iterator().next(); // �Ō�̃X���b�h�����Ă��邾���c +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// +// System.out.println("===== All Statements Backward ====="); +// TracePoint tp = null; +// ExtractedStructure e = null; +// DeltaAliasCollector dac = new DeltaAliasCollector(); +// long restart = 0L; +// for(;;) { +// tp = trace.traverseStatementsInTraceBackward(new IStatementVisitor() { +// @Override +// public boolean preVisitStatement(Statement statement) { +// System.out.println("pre:" + statement.getThreadNo() + ":" + statement.getTimeStamp()); +// if(statement instanceof FieldUpdate) { +// FieldUpdate fu = (FieldUpdate) statement; +// if(!Trace.isNull(fu.getValueObjId()) && !Trace.isPrimitive(fu.getValueClassName())) { +// return true; +// } +// } +// return false; +// } +// +// @Override +// public boolean postVisitStatement(Statement statement) { +// System.out.println("post:" + statement.getThreadNo() + ":" + statement.getTimeStamp()); +// return false; +// } +// }, restart); +// if(tp == null || !tp.isValid()) break; +// e = dex.extract(new Reference(jHotDrawSelect3_1[0], jHotDrawSelect3_1[1], jHotDrawSelect3_1[2], jHotDrawSelect3_1[3]), tp, dac); +// dex.extract(tp); +// Statement statement = tp.getStatement(); +// if(statement instanceof MethodInvocation) { +// restart = ((MethodInvocation)tp.getStatement()).getCalledMethodExecution().getExitTime(); +// } else { +// restart = tp.getStatement().getTimeStamp(); +// } +// } +// trace.traverseStatementsInTraceBackward(new IStatementVisitor() { +// @Override +// public boolean preVisitStatement(Statement statement) { +// System.out.println("post:" + statement.getClass().getName() + ":" + statement.getTimeStamp()); +// return false; +// } +// @Override +// public boolean postVisitStatement(Statement statement) { +// System.out.println("pre:" + statement.getClass().getName() + ":" + statement.getTimeStamp()); +// return false; +// } +// }); +// } + // �Q�ƌ��̃I�u�W�F�N�gId -// ExtractedStructure e = s.extract(new Reference(null, null, "E", "C"), tp, dac); -// ExtractedStructure e = s.extract(new Reference(null, null, "D", "C"), tp, dac); -// ExtractedStructure e = s.extract(new Reference(null, null, "worstCase.P", "worstCase.M"), tp, dac); -// ExtractedStructure e = s.extract(new Reference(null, null, "sample1.D", "sample1.C"), tp, dac); -// ExtractedStructure e = s.extract(new Reference(null, null, "sampleArray.D", "sampleArray.C"), tp, dac); - ExtractedStructure e = s.extract(new Reference(null, null, "sampleCollection.D", "sampleCollection.C"), tp, dac); -// ExtractedStructure e = s.extract(new Reference(null, null, "sampleCreate.D", "sampleCreate.C"), tp, dac); -// ExtractedStructure e = s.extract(new Reference(null, null, "sampleStatic.D", "sampleStatic.C"), tp, dac); - +// ExtractedStructure e = dex.extract(new Reference(null, null, "E", "C"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "D", "C"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "worstCase.P", "worstCase.M"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "sample1.D", "sample1.C"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "sampleArray.D", "sampleArray.C"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "sampleCollection.D", "sampleCollection.C"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "sampleCreate.D", "sampleCreate.C"), tp, dac); +// ExtractedStructure e = dex.extract(new Reference(null, null, "sampleStatic.D", "sampleStatic.C"), tp, dac); + // HashSet marked = trace.getMarkedMethodSignatures(1255991806833871L, 1255991808597322L); // HashSet marked = trace.getMarkedMethodSignatures(1699553004208835L, 1699553004739523L); // System.out.println("===== Marked Methods ====="); @@ -83,32 +131,363 @@ // Change! // setArray, setCollection(2��ڈȍ~�͕K�v�Ȃ�) , foreach(thread) -// ArrayList��add����ĂȂ� -// �t�B�[���h�ɑ������Ă��Ȃ� + // ArrayList��add����ĂȂ� + // �t�B�[���h�ɑ������Ă��Ȃ� // HashMap threads = trace.getAllThreads(); - for(ThreadInstance ti: threads.values()) { - ArrayList roots = ti.getRoot(); - for(MethodExecution root: roots) { - traverseMethodExecution(root); +// for(ThreadInstance ti: threads.values()) { +// ArrayList roots = ti.getRoot(); +// for(MethodExecution root: roots) { +// traverseMethodExecution(root); +// } +// } + + Map argsMap = new HashMap<>(); + setArgmentsForDeltaExtract(argsMap); +// String argsKey = "ArgoUMLPlace1_1"; //���o�������f���^�̈������i�[����Map��key + String argsKey = "ArgoUMLSelect0_1"; //���o�������f���^�̈������i�[����Map��key +// String argsKey = "sampleStatic"; //���o�������f���^�̈������i�[����Map��key +// String argsKey = "worstCase"; //���o�������f���^�̈������i�[����Map��key +// String argsKey = "sample1"; //���o�������f���^�̈������i�[����Map��key + long time = System.nanoTime(); + TraceJSON trace = new TraceJSON(argsMap.get(argsKey)[4]); + DeltaExtractorJSON s = new DeltaExtractorJSON(trace); + HashMap threads = trace.getAllThreads(); + List eList = new ArrayList<>(); + List dacList = new ArrayList<>(); + for (ThreadInstance thread: threads.values()) { + TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); + Reference reference = new Reference(argsMap.get(argsKey)[0], argsMap.get(argsKey)[1], argsMap.get(argsKey)[2], argsMap.get(argsKey)[3]); + reference.setCollection(true); +// reference.setArray(true); +// reference.setFinalLocal(true); +// reference.setCreation(true); + DeltaAliasCollector dac = new DeltaAliasCollector(); + ExtractedStructure e = s.extract(reference, tp, dac); + if (e != null) { + eList.add(e); + dacList.add(dac); + System.out.println("add" + eList.size()); } + System.out.println("---------------------------"); } - - DeltaViewer dv = new DeltaViewer(e, dac); - List aliasList = new ArrayList<>(dac.getAliasList()); -// dv.setCoordinatorPoint(1200, 100); - dv.init(); -// dv.update(); - for(int i = 0; i < aliasList.size(); i++) { - System.out.println(aliasList.get(i).getObjectId() + ", " + aliasList.get(i).getMethodSignature() + " l." + aliasList.get(i).getLineNo() + " : " + aliasList.get(i).getAliasType().toString()); - } - for(int i = 0; i <= aliasList.size(); i++) { - dv.stepToAnimation(i); -// dv.update(); - } - -/* - * ���������� - * +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// //ExtractedStructure e = s.extract(new Reference(null, null, "sampleCollection.D", "sampleCollection.C"), tp, new IAliasCollector() { +// String ArgmentsKey = "jEditSelect"; //���o�������f���^�̈������i�[����Map��key +// ExtractedStructure e = s.extract(new Reference(argsMap.get(ArgmentsKey)[0], argsMap.get(ArgmentsKey)[1], argsMap.get(ArgmentsKey)[2], argsMap.get(ArgmentsKey)[3]), tp, new IAliasCollector() { +// @Override +// public void addAlias(Alias alias) { +// System.out.println(alias.getAliasType().toString() + ":" + alias.getObjectId() +"," + alias.getIndex() + "," + alias.getMethodSignature() + "," + alias.getLineNo()); +// } +// @Override +// public void changeTrackingObject(String from, String to) { +// System.out.println("Change:" + from + "�@=>�@" + to); +// } +// }); + +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// ExtractedStructure e = s.extract(new Reference(argsMap.get(argsKey)[0], argsMap.get(argsKey)[1], argsMap.get(argsKey)[2], argsMap.get(argsKey)[3]), tp, new IAliasCollector() { +// //ExtractedStructure e = s.extract(new Reference(candId1, candId2, argsMap.get(ArgmentsKey)[2], argsMap.get(ArgmentsKey)[3]), tp, new IAliasCollector() { +// @Override +// public void addAlias(Alias alias) { +// System.out.println(alias.getAliasType().toString() + ":" + alias.getObjectId() +"," + alias.getIndex() + "," + alias.getMethodSignature() + "," + alias.getLineNo()); +// } +// @Override +// public void changeTrackingObject(String from, String to) { +// System.out.println("Change:" + from + "�@=>�@" + to); +// } +// }); + +// TraceJSON trace = new TraceJSON("traces\\_finalLocal.txt"); +// DeltaExtractorJSON s = new DeltaExtractorJSON(trace); +// HashMap threads = trace.getAllThreads(); +// ThreadInstance thread = threads.values().iterator().next(); +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// ExtractedStructure e = s.extract(new Reference(null, null, "finalLocal.Main$1Test", "finalLocal.Main$A"), tp); + +// TraceJSON trace = new TraceJSON("traces\\__arraySample.txt"); +// DeltaExtractorJSON s = new DeltaExtractorJSON(trace); +// HashMap threads = trace.getAllThreads(); +// for (ThreadInstance thread: threads.values()) { +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// ExtractedStructure e = s.extract(new Reference(null, null, "arraySample.D", "arraySample.C"), tp); +// s.extract(e.getDelta().getSrcSide().get(2), e.getCoordinator().getEntryPoint()); +// break; +// } + +// TraceJSON trace = new TraceJSON("traces\\__arraySample.txt"); +// DeltaExtractorJSON s = new DeltaExtractorJSON(trace); +// HashMap threads = trace.getAllThreads(); +// ThreadInstance thread = threads.values().iterator().next(); +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// Reference ref = new Reference(null, null, "[Ljava.lang.Object;", "arraySample.B"); +// ref.setArray(true); +// ExtractedStructure e = s.extract(ref, tp); + +// TraceJSON trace = new TraceJSON("traces\\_threadSample.txt"); +// DeltaExtractor s = new DeltaExtractorJSON(trace); +// HashMap threads = trace.getAllThreads(); +// Iterator it = threads.values().iterator(); +// it.next(); +// it.next(); +// ThreadInstance thread = it.next(); +// TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); +// ExtractedStructure e = s.extract(new Reference(null, null, "threadSample.D", "threadSample.C"), tp); + +// DeltaExtractor s = new DeltaExtractor("documents\\finalLocal.txt"); +// ExtractedStructure es = s.extract(); +// s.extract("framework.RWT.RWTFrame3D", +// "fight3D.CharacterSelectContainer"); +// s.extract("framework.B", "application.SubC"); +// s.extract("application.SubA", "framework.B"); +// FrameworkUsage usage = extractor.extract("framework.B", +// "application.SubC"); +// FrameworkUsage usage = extractor.extract("application.SubA", +// "framework.B"); +// s.extract("framework.model3D.Object3D", +// "javax.media.j3d.TransformGroup"); +// s.extract("fight3D.Character", "fight3D.WeaponModel"); +// s.extract("test.E","test.C"); +// ExtractedStructure e = s.extract(new Reference("finalLocal.Main$1Test", "finalLocal.Main$A", null, null)); + + // --------------- Eclipse Core --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\eclipse-Core.txt"); +// CallTree m = null; +// ExtractedStructure e = null; +// do { +// if (m == null) { +// m = s.getCallTreeBackwardly("public boolean java.util.HashSet.add("); +// } else { +// m = s.getCallTreeBackwardly("public boolean java.util.HashSet.add(", m.getStartLine() - 1); +// } +// if (m != null) { +// ArrayList argments = m.getArguments(); +// System.out.println(m.getSignature() + ":" + argments.size()); +// for (int i = 0; i < argments.size(); i++) { +// if (argments.get(i).getActualType().equals("org.eclipse.ui.internal.registry.ActionSetDescriptor")) { +// e = s.extract(m, argments.get(i)); +// break; +// } +// } +// } +// } while (m != null); + + + // --------------- Eclipse UI --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\eclipse-ContextMenu.txt"); +// CallTree m = null; +// ExtractedStructure e = null; +// do { +// if (m == null) { +// m = s.getCallTreeBackwardly("private void org.eclipse.jface.action.ContributionManager.addToGroup("); +// } else { +// m = s.getCallTreeBackwardly("private void org.eclipse.jface.action.ContributionManager.addToGroup(", m.getStartLine() - 1); +// } +// if (m != null) { +// ArrayList argments = m.getArguments(); +// System.out.println(m.getSignature() + ":" + argments.size()); +// for (int i = 0; i < argments.size(); i++) { +// if (argments.get(i).getActualType().equals("org.eclipse.ui.internal.PluginActionCoolBarContributionItem")) { +// e = s.extract(m, argments.get(i)); +// break; +// } +// } +// } +// } while (m != null); + + /////////////////////////////////////////////////////////////////////////////////// + // // + // ICSME2015���e�p // + // // + /////////////////////////////////////////////////////////////////////////////////// + + // --------------- Eclipse (2014/12/6 �v���O�����������؎��� �ۑ�1, �ȉ���1��ڂ̃f���^) --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\eclipse-Console2.txt"); +// ExtractedStructure e = null; +// do { +// System.out.println(System.nanoTime() - time); +// if (e == null) { +// e = s.extract(new Reference(null, null, "org.eclipse.jface.action.ActionContributionItem", +// "org.eclipse.ui.console.actions.ClearOutputAction")); +// } else { +// e = s.extract(new Reference(null, null, "org.eclipse.jface.action.ActionContributionItem", +// "org.eclipse.ui.console.actions.ClearOutputAction"), e.getCreationCallTree().getEntryPoint()); +// } +// } while (e != null); + + + // --------------- Eclipse (2014/12/19-20 �v���O�����������؎��� �ۑ�2, �ȉ���2��ڂ̃f���^) --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\eclipse-JavaEditor.txt"); +// ExtractedStructure e = null; +// do { +// System.out.println(System.nanoTime() - time); +// if (e == null) { +// e = s.extract(new Reference(null, null, "org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer", +// "org.eclipse.jface.text.contentassist.ContentAssistant")); +// } else { +// e = s.extract(new Reference(null, null, "org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer", +// "org.eclipse.jface.text.contentassist.ContentAssistant"), e.getCreationCallTree().getEntryPoint()); +// } +// } while (e != null); + + + // --------------- ArgoUML (2014/12/19-20 �v���O�����������؎��� �ۑ�3, �ȉ���1��ڂ̃f���^) --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\ArgoUML-3.txt"); +// MethodExecution m = null; +// ExtractedStructure e = null; +// do { +// System.out.println(System.nanoTime() - time); +// if (m == null) { +// m = s.getLastMethodExecution("protected void org.tigris.gef.base.SelectionManager.addFig("); +// } else { +// m = s.getLastMethodExecution("protected void org.tigris.gef.base.SelectionManager.addFig(", m.getEntryPoint()); +// } +// if (m != null) { +// ArrayList argments = m.getArguments(); +// System.out.println(m.getSignature() + ":" + argments.size()); +// for (int i = 0; i < argments.size(); i++) { +// if (argments.get(i).getActualType().equals("org.argouml.uml.diagram.static_structure.ui.FigClass")) { +// e = s.extract(m.getEntryPoint(), argments.get(i)); +// break; +// } +// } +// } +// } while (m != null); + + + // --------------- ArgoUML (2014/12/19-20 �v���O�����������؎��� �ۑ�4, �ȉ���3��ڂ̃f���^) --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\ArgoUML-3.txt"); +// MethodExecution m = null; +// ExtractedStructure e = null; +// do { +// System.out.println(System.nanoTime() - time); +// if (m == null) { +// m = s.getLastMethodExecution("public abstract interface boolean java.util.List.add("); +// } else { +// m = s.getLastMethodExecution("public abstract interface boolean java.util.List.add(", m.getEntryPoint()); +// } +// if (m != null) { +// ArrayList argments = m.getArguments(); +// System.out.println(m.getSignature() + ":" + argments.size()); +// for (int i = 0; i < argments.size(); i++) { +// if (argments.get(i).getActualType().equals("org.argouml.uml.diagram.static_structure.ui.FigClass")) { +// e = s.extract(m.getEntryPoint(), argments.get(i)); +// break; +// } +// } +// } +// } while (m != null); + + /////////////////////////////////////////////////////////////////////////////////// + // // + // SANER2016���e�p // + // // + /////////////////////////////////////////////////////////////////////////////////// + + // --------------- Eclipse SWT (2015/10/31 �A�[�L�e�N�`���������؎��� �ۑ�1) --------------- + // ��1(1st�f���^), �ȉ��̃f���^ +// DeltaExtractor s = new DeltaExtractor("documents\\eclipse-Console2.txt"); +// MethodExecution m = null; +// ExtractedStructure e = null; +// System.out.println(System.nanoTime() - time); +// do { +// if (m == null) { +// m = s.getLastMethodExecution("public void org.eclipse.jface.action.Action.runWithEvent("); +// } else { +// TracePoint nextTp = m.getEntryPoint(); +// nextTp.stepBackOver(); +// m = s.getLastMethodExecution("public void org.eclipse.jface.action.Action.runWithEvent(", nextTp); +// } +// if (m != null) { +// ArrayList argments = m.getArguments(); +// for (int i = 0; i < argments.size(); i++) { +// if (argments.get(i).getActualType().equals("org.eclipse.swt.widgets.Event")) { +// System.out.println(System.nanoTime() - time); +// e = s.extract(m.getEntryPoint(), argments.get(i)); +// break; +// } +// } +// } +// } while (e == null); +// System.out.println(System.nanoTime() - time); +// System.out.println("//////////////////////////////////"); + + // ��2,3(2nd�f���^), ��1�̑���, �ȉ��̃f���^ +// Reference nextTarget = e.getDelta().getSrcSide().get(6); +// e = s.extract(nextTarget, e.getCoordinator().getEntryPoint()); + + + // --------------- Eclipse JDT (2015/10/31 �A�[�L�e�N�`���������؎��� �ۑ�2) --------------- + // ��1,2(1st�f���^), �ȉ��̃f���^(���o�Ƃ��Ă�2��) +// DeltaExtractor s = new DeltaExtractor("documents\\eclipse-Debug1.txt"); +// MethodExecution m = null; +// +// System.out.println(System.nanoTime() - time); +// ExtractedStructure e = null; +// do { +// if (m == null) { +// m = s.getLastMethodExecution("public boolean org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.handleBreakpointEvent("); +// } else { +// TracePoint nextTp = m.getEntryPoint(); +// nextTp.stepBackOver(); +// m = s.getLastMethodExecution("public boolean org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint.handleBreakpointEvent(", nextTp); +// } +// if (m != null) { +// ArrayList argments = m.getArguments(); +// for (int i = 0; i < argments.size(); i++) { +// if (argments.get(i).getActualType().equals("org.eclipse.jdi.internal.event.BreakpointEventImpl")) { +// System.out.println(System.nanoTime() - time); +// e = s.extract(m.getEntryPoint(), argments.get(i)); +// break; +// } +// } +// } +// } while (e == null); +// Reference nextTarget = e.getDelta().getDstSide().get(3); // EventDispatcher$1 -> EventSetImpl +// e = s.extract(nextTarget, m.getEntryPoint()); +// System.out.println(System.nanoTime() - time); +// System.out.println("//////////////////////////////////"); +// +// // ��3(2nd�f���^), �ȉ��̃f���^ +// MethodExecution m2 = e.getCoordinator().getChildren().get(21); +// e = s.extract(m2.getExitPoint(), new ObjectReference("859038530", "org.eclipse.jdi.internal.jdwp.JdwpCommandPacket")); +// System.out.println(System.nanoTime() - time); +// System.out.println("//////////////////////////////////"); +// +// +// // ��4(3rd�f���^), �ȉ��̃f���^ +// m = e.getCoordinator().getChildren().get(0).getChildren().get(1).getChildren().get(4); +// Reference lastTarget = new Reference(e.getDelta().getDstSide().get(1).getSrcObject(), e.getDelta().getDstSide().get(0).getDstObject()); +// lastTarget.setCollection(true); +// e = s.extract(lastTarget, m.getExitPoint()); + + + // --------------- ArgoUML + GEF (2014/12/19-20 �v���O�����������؎��� �ۑ�3, �ȉ��̃f���^) --------------- +// DeltaExtractor s = new DeltaExtractor("documents\\ArgoUML-3.txt"); +// MethodExecution m = null; +// ExtractedStructure e = null; +// System.out.println(System.nanoTime() - time); +// m = s.getLastMethodExecution("public void org.argouml.uml.diagram.ui.ActionRemoveFromDiagram.actionPerformed("); +// m = s.getLastMethodExecution("public java.util.Vector org.tigris.gef.base.SelectionManager.getFigs("); +// if (m != null) { +// System.out.println(System.nanoTime() - time); +// Reference r = new Reference(null, null, "java.util.ArrayList", "org.argouml.uml.diagram.static_structure.ui.SelectionClass"); +// r.setCollection(true); +// e = s.extract(r, m.getEntryPoint()); +// } + + +// System.out.println(System.nanoTime() - time); +// System.out.println("//////////////////////////////////"); +// // s.extractArg(e.getCoodinator(), 123456789); +// // s.getCallHistory(e.getCoodinator()); + + + startDeltaViewer(eList.get(0), dacList.get(0)); + } + + /* + * ���������� + * ===== Marked Methods ===== void worstCase.O.passL(worstCase.L) worstCase.L worstCase.I.getL() @@ -143,15 +522,15 @@ worstCase.H worstCase.G.getH() worstCase.I worstCase.H.getI() worstCase.I worstCase.B.getI() - */ + */ // HashSet all = trace.getAllMethodSignatures(); // System.out.println("===== All Methods ====="); // for (String method: all) { // System.out.println(method); // } -/* - * ���������� - * + /* + * ���������� + * ===== All Methods ===== worstCase.F worstCase.C.getF() worstCase.E worstCase.D.getE() @@ -185,30 +564,30 @@ worstCase.H worstCase.G.getH() worstCase.L() worstCase.I worstCase.B.getI() - */ - + */ + // ArrayList specified = trace.getMethodExecutions("void"); // System.out.println("===== Specified Methods ====="); // for (MethodExecution method: specified) { // System.out.println(method.getSignature()); // } -/* - * ���������� - * + /* + * ���������� + * ===== Specified Methods ===== void worstCase.A.m() void worstCase.N.passI(worstCase.I) void worstCase.O.passL(worstCase.L) void worstCase.P.setM(worstCase.M) * - */ + */ // HashMap> allExecutions = trace.getAllMethodExecutions(); // System.out.println("===== All Methods and Executions ====="); // for (String method: allExecutions.keySet()) { // System.out.println(method + ":" + allExecutions.get(method).size()); // } -/* - * ���������� - * + /* + * ���������� + * ===== All Methods and Executions ===== worstCase.F worstCase.C.getF():1 worstCase.E worstCase.D.getE():1 @@ -242,14 +621,14 @@ worstCase.H worstCase.G.getH():1 worstCase.L():1 worstCase.I worstCase.B.getI():1 - */ + */ // System.out.println("===== All Statements Forward ====="); // trace.traverseStatementsInTrace(new IStatementVisitor() { // @Override // public boolean preVisitStatement(Statement statement) { // if (statement instanceof FieldUpdate) { // if(trace.isNull((((FieldUpdate) statement).getValueObjId()))) { -// +// // } // } // System.out.println("pre:" + statement.getClass().getName() + ":" + statement.getTimeStamp()); @@ -261,9 +640,9 @@ // return false; // } // }); -/* - * ���������� - * + /* + * ���������� + * ===== All Statements Forward ===== pre:org.ntlab.trace.BlockEnter:1699552992988213 post:org.ntlab.trace.BlockEnter:1699552992988213 @@ -421,9 +800,9 @@ post:org.ntlab.trace.MethodInvocation:1699553004606587 post:org.ntlab.trace.MethodInvocation:1699553004208835 post:org.ntlab.trace.MethodInvocation:1699553003253243 - */ - - // Change! + */ + + // Change! // System.out.println("===== All Statements Backward ====="); // TracePoint tp = null; // DeltaAliasCollector dac = new DeltaAliasCollector(); @@ -441,7 +820,7 @@ // } // return false; // } -// +// // @Override // public boolean postVisitStatement(Statement statement) { // System.out.println("post:" + statement.getThreadNo() + ":" + statement.getTimeStamp()); @@ -470,8 +849,24 @@ // return false; // } // }); + + private static void startDeltaViewer(ExtractedStructure e, DeltaAliasCollector dac) { + // TODO Auto-generated method stub + DeltaViewer dv = new DeltaViewer(e, dac); + List aliasList = new ArrayList<>(dac.getAliasList()); +// DeltaViewer dv = new DeltaViewer(e, dac); +// List aliasList = new ArrayList<>(dac.getAliasList()); +// dv.setCoordinatorPoint(1200, 100); + dv.init(); +// dv.update(); +// for(int i = 0; i < aliasList.size(); i++) { +// System.out.println(aliasList.get(i).getObjectId() + ", " + aliasList.get(i).getMethodSignature() + " l." + aliasList.get(i).getLineNo() + " : " + aliasList.get(i).getAliasType().toString()); +// } + for(int i = 0; i <= aliasList.size(); i++) { + dv.stepToAnimation(i); +// dv.update(); + } } - private static void traverseMethodExecution(MethodExecution m) { System.out.println(m.getSignature()); for(Statement ms :m.getStatements()) { @@ -483,9 +878,9 @@ traverseMethodExecution(m2); } } -/* - * ���������� - * + /* + * ���������� + * ===== All Statements Backward ===== post:org.ntlab.trace.MethodInvocation:1699553003253243 post:org.ntlab.trace.MethodInvocation:1699553004208835 @@ -643,5 +1038,31 @@ pre:org.ntlab.trace.MethodInvocation:1699552993730471 post:org.ntlab.trace.BlockEnter:1699552992988213 pre:org.ntlab.trace.BlockEnter:1699552992988213 - */ + */ + + private static void setArgmentsForDeltaExtract(Map map){ + String[] test = {null, null, "org.argouml.uml.diagram.static_structure.ui.FigClass","org.tigris.gef.base.LayerPerspectiveMutable", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("test", test); + String[] testVectorAddElement = {null, null, "java.util.Vector", "org.tigris.gef.base.LayerPerspective", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("testVectorAddElement", testVectorAddElement);//trace.java��"addElement("�ɑΉ�����悤�ɒlj� + String[] sample1 = {null, null, "sample1.D", "sample1.C", "traces\\sample1.trace"}; map.put("sample1", sample1); + String[] sampleArray = {null, null, "sampleArray.D", "sampleArray.C", "traces\\sampleArray.trace"}; map.put("sampleArray", sampleArray); + String[] sampleCollection = {null, null, "sampleCollection.D", "sampleCollection.C", "traces\\sampleCollection.trace"}; map.put("sampleCollection", sampleCollection); + String[] sampleCreate = {null, null, "sampleCreate.D", "sampleCreate.C", "traces\\sampleCreate.trace"}; map.put("sampleCreate", sampleCreate); + String[] sampleStatic = {null, null, "sampleStatic.D", "sampleStatic.C", "traces\\sampleStatic.trace"}; map.put("sampleStatic", sampleStatic); + String[] worstCase = {null, null, "worstCase.P", "worstCase.M", "traces/_worstCase.txt"}; map.put("worstCase", worstCase); + // String[] ArgoUMLSelect0_1 = {"1994249754", "1141430801", "java.util.ArrayList", "org.argouml.uml.diagram.static_structure.ui.SelectionClass","traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("ArgoUMLSelect0_1", ArgoUMLSelect0_1); + String[] ArgoUMLSelect0_1 = {"1994249754", "1141430801", null, null,"traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("ArgoUMLSelect0_1", ArgoUMLSelect0_1); + /*Vector.addElemnt()�ɑΉ��ς�*/String[] ArgoUMLDelete0_2 = {"1784213708", "1337038091", "java.util.Vector", "org.argouml.uml.diagram.static_structure.ui.FigClass", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("ArgoUMLDelete0_2", ArgoUMLDelete0_2); + /*�X�ɉߋ�mouse.Pressed(), mouseReleased()*/String[] ArgoUMLPlace1_1 = {null, null, "java.util.ArrayList", "org.argouml.uml.diagram.static_structure.ui.FigClass", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("ArgoUMLPlace1_1", ArgoUMLPlace1_1); + String[] ArgoUMLSelect1_2 = {"1994249754", "1141430801", "java.util.ArrayList", "org.argouml.uml.diagram.static_structure.ui.SelectionClass", "traces\\ArgoUMLBenchmarkWithMoreStandardClasses.trace"}; map.put("ArgoUMLSelect1_2", ArgoUMLSelect1_2); + String[] jEditSelect2_1 = {"932187140", "1572482885", "java.util.ArrayList", "org.gjt.sp.jedit.textarea.Selection$Range", "traces\\jEditBenchmarkWithMoreStandardClasses.trace"}; map.put("jEditSelect2_1", jEditSelect2_1); + /*List.toArray()�ɑΉ�������K�v������H*/String[] jEditDelete2_2 = {null, null, "org.gjt.sp.jedit.buffer.ContentManager", "java.util.ArrayList", "traces\\jEditBenchmarkWithMoreStandardClasses.trace"}; map.put("jEditDelete2_2", jEditDelete2_2); + String[] jHotDrawSelect3_1 = {"361298449", "212532447", "java.util.LinkedHashSet", "org.jhotdraw.draw.RectangleFigure", "traces\\jHotDrawBenchmarkWithMoreStandardClasses.trace"}; map.put("jHotDrawSelect3_1", jHotDrawSelect3_1); + String[] jHotDrawMove3_2 = {"778703711", "212532447", "org.jhotdraw.draw.tool.DefaultDragTracker", "org.jhotdraw.draw.RectangleFigure", "traces\\jHotDrawBenchmarkWithMoreStandardClasses.trace"}; map.put("jHotDrawMove3_2", jHotDrawMove3_2); + /*�s��*/String[] jHotDrawMove3_2_1 = {null, null, "java.util.ArrayList", "org.jhotdraw.draw.RectangleFigure", "traces\\jHotDrawBenchmarkWithMoreStandardClasses.trace"}; map.put("jHotDrawMove3_2_1", jHotDrawMove3_2_1); + String[] jHotDrawPlace4_1 = {"1284329882", "212532447", "java.util.HashMap", "org.jhotdraw.draw.RectangleFigure", "traces\\jHotDrawBenchmarkWithMoreStandardClasses.trace"}; map.put("jHotDrawPlace4_1", jHotDrawPlace4_1); + String[] jHotDrawSelect4_2 = {"361298449", "212532447", "java.util.LinkedHashSet", "org.jhotdraw.draw.RectangleFigure", "traces\\jHotDrawBenchmarkWithMoreStandardClasses.trace"}; map.put("jHotDrawSelect4_2", jHotDrawSelect4_2); + } + } + + diff --git a/traces/ArgoUMLBenchmark.trace b/traces/ArgoUMLBenchmark.trace new file mode 100644 index 0000000..b14fdc4 --- /dev/null +++ b/traces/ArgoUMLBenchmark.trace Binary files differ diff --git a/traces/ArgoUMLBenchmarkWithMoreStandardClasses.trace b/traces/ArgoUMLBenchmarkWithMoreStandardClasses.trace new file mode 100644 index 0000000..989a070 --- /dev/null +++ b/traces/ArgoUMLBenchmarkWithMoreStandardClasses.trace Binary files differ diff --git a/traces/jEditBenchmarkWithMoreStandardClasses.trace b/traces/jEditBenchmarkWithMoreStandardClasses.trace new file mode 100644 index 0000000..c45dc64 --- /dev/null +++ b/traces/jEditBenchmarkWithMoreStandardClasses.trace Binary files differ diff --git a/traces/jHotDrawBenchmarkWithMoreStandardClasses.trace b/traces/jHotDrawBenchmarkWithMoreStandardClasses.trace new file mode 100644 index 0000000..517c6c2 --- /dev/null +++ b/traces/jHotDrawBenchmarkWithMoreStandardClasses.trace Binary files differ