diff --git a/src/org/ntlab/deltaExtractor/Alias.java b/src/org/ntlab/deltaExtractor/Alias.java index 7d83a6e..5477266 100644 --- a/src/org/ntlab/deltaExtractor/Alias.java +++ b/src/org/ntlab/deltaExtractor/Alias.java @@ -1,72 +1,76 @@ -package org.ntlab.deltaExtractor; -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.Statement; -import org.ntlab.trace.TracePoint; -/** - * �I�u�W�F�N�g�̎Q�Ə��(�G�C���A�X)��\���N���X - * @author Isitani - * - */ -public class Alias { - private String objectId; - private TracePoint occurrencePoint; // ���Y�I�u�W�F�N�g�̎Q�Ƃ��s���Ă�����s�ӏ��ɑΉ�����TracePoint - private AliasType aliasType; - private int index; - - public enum AliasType { - // ���\�b�h�ւ̓��� - FORMAL_PARAMETER, - THIS, - METHOD_INVOCATION, - CONSTRACTOR_INVOCATION, - - // �ǐՃI�u�W�F�N�g�̐؂�ւ� - FIELD, - CONTAINER, - ARRAY_ELEMENT, - ARRAY, - ARRAY_CREATE, - - // ���\�b�h����̏o�� - ACTUAL_ARGUMENT, - RECEIVER, - RETURN_VALUE - } - - public Alias(AliasType aliasType, int index, String objectId, TracePoint occurrencePoint) { - this.aliasType = aliasType; - this.index = index; - this.objectId = objectId; - this.occurrencePoint = occurrencePoint; - } - - public AliasType getAliasType() { - return aliasType; - } - - public int getIndex() { - return index; - } - - public String getObjectId() { - return objectId; - } - - public TracePoint getOccurrencePoint() { - return occurrencePoint; - } - - public MethodExecution getMethodExecution() { - return occurrencePoint.getMethodExecution(); - } - - public String getMethodSignature() { - return occurrencePoint.getMethodExecution().getCallerSideSignature(); - } - - public int getLineNo() { - Statement statement = occurrencePoint.getStatement(); - return statement.getLineNo(); - } - +package org.ntlab.deltaExtractor; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.Statement; +import org.ntlab.trace.TracePoint; +/** + * �I�u�W�F�N�g�̎Q�Ə��(�G�C���A�X)��\���N���X + * @author Isitani + * + */ +public class Alias { + private String objectId; + private TracePoint occurrencePoint; // ���Y�I�u�W�F�N�g�̎Q�Ƃ��s���Ă�����s�ӏ��ɑΉ�����TracePoint + private AliasType aliasType; + private int index; + + public enum AliasType { + // ���\�b�h�ւ̓��� + FORMAL_PARAMETER, + THIS, + METHOD_INVOCATION, + CONSTRACTOR_INVOCATION, + + // �ǐՃI�u�W�F�N�g�̐؂�ւ� + FIELD, + CONTAINER, + ARRAY_ELEMENT, + ARRAY, + ARRAY_CREATE, + + // ���\�b�h����̏o�� + ACTUAL_ARGUMENT, + RECEIVER, + RETURN_VALUE + } + + public Alias(AliasType aliasType, int index, String objectId, TracePoint occurrencePoint) { + this.aliasType = aliasType; + this.index = index; + this.objectId = objectId; + this.occurrencePoint = occurrencePoint; + } + + public AliasType getAliasType() { + return aliasType; + } + + public int getIndex() { + return index; + } + + public String getObjectId() { + return objectId; + } + + public TracePoint getOccurrencePoint() { + return occurrencePoint; + } + + public MethodExecution getMethodExecution() { + return occurrencePoint.getMethodExecution(); + } + + public String getMethodSignature() { + return occurrencePoint.getMethodExecution().getCallerSideSignature(); + } + + public int getLineNo() { + try { + Statement statement = occurrencePoint.getStatement(); + return statement.getLineNo(); + } catch (Exception e) { + return -1; + } + } + } \ No newline at end of file diff --git a/src/org/ntlab/deltaExtractor/Delta.java b/src/org/ntlab/deltaExtractor/Delta.java index ea47d5b..7964f23 100644 --- a/src/org/ntlab/deltaExtractor/Delta.java +++ b/src/org/ntlab/deltaExtractor/Delta.java @@ -1,27 +1,27 @@ -package org.ntlab.deltaExtractor; - -import java.util.ArrayList; - -import org.ntlab.trace.Reference; - -public class Delta { - - private ArrayList srcSide = new ArrayList(); - private ArrayList dstSide = new ArrayList(); - - public void addSrcSide(Reference r){ - getSrcSide().add(r); - } - - public void addDstSide(Reference r){ - getDstSide().add(r); - } - - public ArrayList getSrcSide() { - return srcSide; - } - - public ArrayList getDstSide() { - return dstSide; - } -} +package org.ntlab.deltaExtractor; + +import java.util.ArrayList; + +import org.ntlab.trace.Reference; + +public class Delta { + + private ArrayList srcSide = new ArrayList(); + private ArrayList dstSide = new ArrayList(); + + public void addSrcSide(Reference r){ + getSrcSide().add(r); + } + + public void addDstSide(Reference r){ + getDstSide().add(r); + } + + public ArrayList getSrcSide() { + return srcSide; + } + + public ArrayList getDstSide() { + return dstSide; + } +} diff --git a/src/org/ntlab/deltaExtractor/DeltaAugmentationInfo.java b/src/org/ntlab/deltaExtractor/DeltaAugmentationInfo.java index 82a373d..d887b4f 100644 --- a/src/org/ntlab/deltaExtractor/DeltaAugmentationInfo.java +++ b/src/org/ntlab/deltaExtractor/DeltaAugmentationInfo.java @@ -1,34 +1,34 @@ -package org.ntlab.deltaExtractor; - -import org.ntlab.trace.AugmentationInfo; - -public class DeltaAugmentationInfo extends AugmentationInfo { - private Boolean isCoodinator = false; - private Boolean isSetter = true; - private int traceObjectId = 0; - - public void setTraceObjectId(int traceObjectId) { - this.traceObjectId = traceObjectId; - } - - public int getTraceObjectId() { - return traceObjectId; - } - - public void setSetterSide(boolean isSetter) { - this.isSetter = isSetter; - } - - public boolean isSetterSide() { - return isSetter; - } - - public void setCoodinator(boolean isCoodinator) { - this.isCoodinator = isCoodinator; - } - - public boolean isCoodinator() { - return isCoodinator; - } - -} +package org.ntlab.deltaExtractor; + +import org.ntlab.trace.AugmentationInfo; + +public class DeltaAugmentationInfo extends AugmentationInfo { + private Boolean isCoodinator = false; + private Boolean isSetter = true; + private int traceObjectId = 0; + + public void setTraceObjectId(int traceObjectId) { + this.traceObjectId = traceObjectId; + } + + public int getTraceObjectId() { + return traceObjectId; + } + + public void setSetterSide(boolean isSetter) { + this.isSetter = isSetter; + } + + public boolean isSetterSide() { + return isSetter; + } + + public void setCoodinator(boolean isCoodinator) { + this.isCoodinator = isCoodinator; + } + + public boolean isCoodinator() { + return isCoodinator; + } + +} diff --git a/src/org/ntlab/deltaExtractor/DeltaExtractor.java b/src/org/ntlab/deltaExtractor/DeltaExtractor.java index 586c3ff..23fc536 100644 --- a/src/org/ntlab/deltaExtractor/DeltaExtractor.java +++ b/src/org/ntlab/deltaExtractor/DeltaExtractor.java @@ -1,1117 +1,1115 @@ -package org.ntlab.deltaExtractor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import org.ntlab.trace.FieldAccess; -import org.ntlab.trace.FieldUpdate; -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.MethodInvocation; -import org.ntlab.trace.ObjectReference; -import org.ntlab.trace.Reference; -import org.ntlab.trace.Statement; -import org.ntlab.trace.Trace; -import org.ntlab.trace.TracePoint; - -/** - * �f���^���o�A���S���Y��(�z��ւ̃A�N�Z�X�𐄑�����]���̃o�[�W����) - * extract(...)���\�b�h�Q�Œ��o����B - * - * @author Nitta - * - */ -public class DeltaExtractor { - protected static final int LOST_DECISION_EXTENSION = 0; // ��{�� 0 �ɐݒ�Bfinal�ϐ��̒ǐՃA���S���Y���̕s��C����͕s�v�̂͂��B - protected ArrayList data = new ArrayList(); - protected ArrayList objList = new ArrayList(2); - protected ArrayList methodList = new ArrayList(); - protected ExtractedStructure eStructure = new ExtractedStructure(); - protected ObjectReference srcObject = null; - protected ObjectReference dstObject = null; - protected String returnValue; - protected String threadNo; - protected boolean isLost = false; - protected ArrayList checkList = new ArrayList(); - protected Trace trace = null; - protected int finalCount = 0; // final�ϐ������o�ł��Ȃ��”\��������̂ŁA�R���̉������ł��Ȃ������ꍇ�ł����΂炭�ǐՂ��‚Â��� - - protected static final boolean DEBUG1 = true; - protected static final boolean DEBUG2 = true; - protected final IAliasCollector defaultAliasCollector = new IAliasCollector() { - @Override - public void changeTrackingObject(String from, String to) { - } - @Override - public void addAlias(Alias alias) { - } - }; - - public DeltaExtractor(String traceFile) { - trace = new Trace(traceFile); - } - - public DeltaExtractor(Trace trace) { - this.trace = trace; - } - -// public MethodExecution getMethodExecution(Reference createdReference, MethodExecution before) { -// return trace.getMethodExecution(createdReference, before); -// } -// -// public MethodExecution getMethodExecution(String methodSignature) { -// return trace.getMethodExecution(methodSignature); -// } -// -// public MethodExecution getMethodExecutionBackwardly(String methodSignature) { -// return trace.getMethodExecutionBackwardly(methodSignature); -// } -// -// public MethodExecution getCollectionTypeMethodExecution(Reference r, MethodExecution before) { -// return trace.getCollectionTypeMethodExecution(r, before); -// } -// -// public MethodExecution getArraySetMethodExecution(Reference r, MethodExecution before) { -// return trace.getArraySetMethodExecution(r, before); -// } -// -// public CallTree getLastCallTree(ArrayList refs, -// ArrayList colls, -// ArrayList arrys, -// int endLine, -// Reference[] lastRef) throws TraceFileException { -// return trace.getLastCallTree(refs, colls, arrys, endLine, lastRef); -// } - - /** - * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j - * @param trace�@��͑Ώۃg���[�X - * @param methodExecution �T�����郁�\�b�h���s - * @param objList�@�ǐՒ��̃I�u�W�F�N�g - * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s - * @return ���‚������R�[�f�B�l�[�^ - * @throws TraceFileException - */ - protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution) { - return callerSearch(trace, tracePoint, objList, childMethodExecution, defaultAliasCollector); - } - - /** - * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j - * @param trace�@��͑Ώۃg���[�X - * @param methodExecution �T�����郁�\�b�h���s - * @param objList�@�ǐՒ��̃I�u�W�F�N�g - * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s - * @return ���‚������R�[�f�B�l�[�^ - * @throws TraceFileException - */ - protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution, IAliasCollector aliasCollector) { - MethodExecution methodExecution = tracePoint.getMethodExecution(); - methodExecution.setAugmentation(new DeltaAugmentationInfo()); - eStructure.createParent(methodExecution); - String thisObjectId = methodExecution.getThisObjId(); - ArrayList removeList = new ArrayList(); // �ǐՂ��Ă���I�u�W�F�N�g���ō폜�ΏۂƂȂ��Ă������ - ArrayList creationList = new ArrayList(); // ���̃��\�b�h���s���ɐ������ꂽ�I�u�W�F�N�g - int existsInFields = 0; // ���̃��\�b�h���s���Ńt�B�[���h�ɗR�����Ă���I�u�W�F�N�g�̐�(1�ȏ�Ȃ炱�̃��\�b�h���s����this�Ɉˑ�) - boolean isTrackingThis = false; // �Ăяo�����this�Ɉˑ����� - boolean isSrcSide = true; // �Q�ƌ����Q�Ɛ�̂�����̑��̃I�u�W�F�N�g�̗R�������ǂ���this�I�u�W�F�N�g�ɓ��B������? - ArrayList fieldArrays = new ArrayList(); - ArrayList fieldArrayElements = new ArrayList(); - ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), - Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - - if (childMethodExecution == null) { - // �T���J�n���͈�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� - } - - if (childMethodExecution != null && objList.contains(childMethodExecution.getThisObjId())) { - // �Ăяo�����this�Ɉˑ����� - if (thisObjectId.equals(childMethodExecution.getThisObjId())) { - // �I�u�W�F�N�g���Ăяo���̂Ƃ��݈̂�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� - } - } - - if (childMethodExecution != null && childMethodExecution.isConstructor()) { - // �Ăяo���悪�R���X�g���N�^�������ꍇ - int newIndex = objList.indexOf(childMethodExecution.getThisObjId()); - if (newIndex != -1) { - // �Ăяo���悪�ǐՑΏۂ̃R���X�g���N�^��������field�Ɠ��l�ɏ��� - removeList.add(childMethodExecution.getThisObjId()); - existsInFields++; - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - } - } - - if (childMethodExecution != null && Trace.getMethodName(childMethodExecution.getSignature()).startsWith("access$")) { - // �G���N���[�W���O�C���X�^���X�ɑ΂��郁�\�b�h�Ăяo���������ꍇ - String enclosingObj = childMethodExecution.getArguments().get(0).getId(); // �G���N���[�W���O�C���X�^���X�͑������ɓ����Ă���炵�� - int encIndex = objList.indexOf(enclosingObj); - if (encIndex != -1) { - // thisObject �ɒu����������Afield�Ɠ��l�ɏ��� - removeList.add(enclosingObj); - existsInFields++; - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - } - } - - // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch���ċA�Ăяo�� - while (tracePoint.stepBackOver()) { - Statement statement = tracePoint.getStatement(); - // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� - if (statement instanceof FieldAccess) { - FieldAccess fs = (FieldAccess)statement; - String refObjectId = fs.getValueObjId(); - int index = objList.indexOf(refObjectId); - if (index != -1) { - String ownerObjectId = fs.getContainerObjId(); - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ - removeList.add(refObjectId); - existsInFields++; // set�������get�����o���Ă���”\�������� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - } else { - // ���ڎQ�Ƃ̏ꍇ - if (refObjectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(ownerObjectId, refObjectId, - fs.getContainerClassName(), srcObject.getActualType())); - srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - } else if(refObjectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(ownerObjectId, refObjectId, - fs.getContainerClassName(), dstObject.getActualType())); - dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - } - objList.set(index, ownerObjectId); - } - } else { - // �ŏI�I�ɃI�u�W�F�N�g�̗R�������‚���Ȃ������ꍇ�ɁA�����ŎQ�Ƃ����z������̗v�f�ɗR�����Ă���”\�������� - String refObjType = fs.getValueClassName(); - if (refObjType.startsWith("[L")) { - // �Q�Ƃ����t�B�[���h���z��̏ꍇ - ObjectReference trackingObj = null; - if ((srcObject.getActualType() != null && refObjType.endsWith(srcObject.getActualType() + ";")) - || (srcObject.getCalleeType() != null && refObjType.endsWith(srcObject.getCalleeType() + ";")) - || (srcObject.getCallerType() != null && refObjType.endsWith(srcObject.getCallerType() + ";"))) { - trackingObj = srcObject; - } else if ((dstObject.getActualType() != null && refObjType.endsWith(dstObject.getActualType() + ";")) - || (dstObject.getCalleeType() != null && refObjType.endsWith(dstObject.getCalleeType() + ";")) - || (dstObject.getCallerType() != null && refObjType.endsWith(dstObject.getCallerType() + ";"))) { - trackingObj = dstObject; - } - if (trackingObj != null) { - // �ǐՒ��̃I�u�W�F�N�g�ɁA�z��v�f�Ɠ����^�����ƒI�u�W�F�N�g�����݂���ꍇ - String ownerObjectId = fs.getContainerObjId(); - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ�i���ɗR���̉”\�����Ȃ��Ƃ킩�������_�ŁA���̔z��̗v�f�ɗR�����Ă�����̂Ɛ�������B�j - fieldArrays.add(new ObjectReference(refObjectId, refObjType)); - fieldArrayElements.add(trackingObj); - } else { - // ���ڎQ�Ƃ̏ꍇ(�{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u��������ׂ������A - // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� - // ��蒼��������B) - } - } - } - } - } else if (statement instanceof MethodInvocation) { - MethodExecution prevChildMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); - if (!prevChildMethodExecution.equals(childMethodExecution)) { - // �߂�l - ObjectReference ret = prevChildMethodExecution.getReturnValue(); - if (ret != null) { - int retIndex = -1; - retIndex = objList.indexOf(ret.getId()); - if (retIndex != -1) { - // �߂�l���R�������� - prevChildMethodExecution.setAugmentation(new DeltaAugmentationInfo()); - if (prevChildMethodExecution.isConstructor()) { - // �ǐՑΏۂ�constractor���Ă�ł�����(�I�u�W�F�N�g�̐�����������)field�Ɠ��l�ɏ��� - String newObjId = ret.getId(); - creationList.add(newObjId); - removeList.add(newObjId); - existsInFields++; - // objList.remove(callTree.getThisObjId()); - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(newObjId)); // �ǐՑΏ� - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setSetterSide(false); // getter�Ăяo���Ɠ��l - continue; - } - String retObj = objList.get(retIndex); - if (removeList.contains(retObj)) { - // ��xget�Ō��o���ăt�B�[���h�Ɉˑ����Ă���Ɣ��f�������{���̗R�����߂�l���������Ƃ����������̂ŁA�t�B�[���h�ւ̈ˑ����L�����Z������ - removeList.remove(retObj); - existsInFields--; - if (existsInFields == 0) { - removeList.remove(thisObjectId); - } - } - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(retObj)); // �ǐՑΏ� - TracePoint prevChildTracePoint = tracePoint.duplicate(); - prevChildTracePoint.stepBackNoReturn(); - calleeSearch(trace, prevChildTracePoint, objList, prevChildMethodExecution.isStatic(), retIndex, aliasCollector); // �Ăяo�����T�� - if (objList.get(retIndex) != null && objList.get(retIndex).equals(prevChildMethodExecution.getThisObjId()) - && thisObjectId.equals(prevChildMethodExecution.getThisObjId())) { - // �Ăяo����Ńt�B�[���h�Ɉˑ����Ă����ꍇ�̏��� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� - } - if (isLost) { - checkList.add(objList.get(retIndex)); - isLost = false; - } - } else { - // �ŏI�I�ɃI�u�W�F�N�g�̗R�������‚���Ȃ������ꍇ�ɁA���̖߂�l�Ŏ擾�����z������̗v�f�ɗR�����Ă���”\�������� - String retType = ret.getActualType(); - if (retType.startsWith("[L")) { - // �߂�l���z��̏ꍇ - if ((srcObject.getActualType() != null && retType.endsWith(srcObject.getActualType() + ";")) - || (srcObject.getCalleeType() != null && retType.endsWith(srcObject.getCalleeType() + ";")) - || (srcObject.getCallerType() != null && retType.endsWith(srcObject.getCallerType() + ";"))) { - retType = srcObject.getActualType(); - } else if ((dstObject.getActualType() != null && retType.endsWith(dstObject.getActualType() + ";")) - || (dstObject.getCalleeType() != null && retType.endsWith(dstObject.getCalleeType() + ";")) - || (dstObject.getCallerType() != null && retType.endsWith(dstObject.getCallerType() + ";"))) { - retType = dstObject.getActualType(); - } else { - retType = null; - } - if (retType != null) { - // �{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u�������āA�Ăяo�����T�����ׂ������A - // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� - // ��蒼��������B - } - } - } - } - } - } - } - // --- ���̎��_�� tracePoint �͌Ăяo�������w���Ă��� --- - - // �R���N�V�����^�Ή� - if (methodExecution.isCollectionType()) { - objList.add(thisObjectId); - } - - // �����̎擾 - ArrayList argments = methodExecution.getArguments(); - - // �����ƃt�B�[���h�ɓ���ID�̃I�u�W�F�N�g������ꍇ��z�� - Reference r; - for (int i = 0; i < removeList.size(); i++) { - String removeId = removeList.get(i); - if (argments.contains(new ObjectReference(removeId))) { - removeList.remove(removeId); // �t�B�[���h�ƈ����̗����ɒǐՑΏۂ����݂����ꍇ�A������D�� - } else if(objList.contains(removeId)) { - // �t�B�[���h�ɂ����Ȃ������ꍇ(�������A�I�u�W�F�N�g�̐������t�B�[���h�Ɠ��l�Ɉ���) - objList.remove(removeId); // �ǐՑΏۂ���O�� - if (!removeId.equals(thisObjectId)) { - // �t�B�[���h�ithis ���� removeId �ւ̎Q�Ɓj���f���^�̍\���v�f�ɂȂ� - if (removeId.equals(srcObject.getId())) { - r = new Reference(thisObj, srcObject); - r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? - eStructure.addSrcSide(r); - srcObject = thisObj; - isSrcSide = true; - } else if (removeId.equals(dstObject.getId())) { - r = new Reference(thisObj, dstObject); - r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? - eStructure.addDstSide(r); - dstObject = thisObj; - isSrcSide = false; - } - } - } - } - // --- ���̎��_�� this ���ǐՑΏۂł������Ƃ��Ă� objList �̒����炢������폜����Ă��� --- - - // �����T�� - boolean existsInAnArgument = false; - for (int i = 0; i < objList.size(); i++) { - String objectId = objList.get(i); - if (objectId != null) { - ObjectReference trackingObj = new ObjectReference(objectId); - if (argments.contains(trackingObj)) { - // �������R�������� - existsInAnArgument = true; - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); - } else { - // �R�����ǂ��ɂ����‚���Ȃ����� - boolean isSrcSide2 = true; - trackingObj = null; - if (objectId.equals(srcObject.getId())) { - isSrcSide2 = true; - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - isSrcSide2 = false; - trackingObj = dstObject; - } - if (trackingObj != null) { - // �܂��z������̗v�f��R���Ƃ��ċ^��(������D��) - for (int j = 0; j < argments.size(); j++) { - ObjectReference argArray = argments.get(j); - if (argArray.getActualType().startsWith("[L") - && (trackingObj.getActualType() != null && (argArray.getActualType().endsWith(trackingObj.getActualType() + ";")) - || (trackingObj.getCalleeType() != null && argArray.getActualType().endsWith(trackingObj.getCalleeType() + ";")) - || (trackingObj.getCallerType() != null && argArray.getActualType().endsWith(trackingObj.getCallerType() + ";")))) { - // �^����v������z������̗v�f��R���Ƃ݂Ȃ� - existsInAnArgument = true; - objList.remove(objectId); - objList.add(argArray.getId()); // �ǐՑΏۂ�z��v�f����z��ɒu������ - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(argArray.getId())); - r = new Reference(argArray.getId(), trackingObj.getId(), - argArray.getActualType(), trackingObj.getActualType()); - r.setArray(true); - if (isSrcSide2) { - eStructure.addSrcSide(r); - srcObject = new ObjectReference(argArray.getId(), argArray.getActualType()); - } else { - eStructure.addDstSide(r); - dstObject = new ObjectReference(argArray.getId(), argArray.getActualType()); - } - objectId = null; - break; - } - } - if (objectId != null) { - // ���ɔz��t�B�[���h�̗v�f��R���Ƃ��ċ^��(�t�B�[���h�͈�������) - int index = fieldArrayElements.indexOf(trackingObj); - if (index != -1) { - // �^����v���Ă�̂Ŕz��t�B�[���h�̗v�f��R���Ƃ݂Ȃ� - ObjectReference fieldArray = fieldArrays.get(index); - existsInFields++; - objList.remove(objectId); - r = new Reference(fieldArray.getId(), trackingObj.getId(), - fieldArray.getActualType(), trackingObj.getActualType()); - r.setArray(true); - if (isSrcSide2) { - eStructure.addSrcSide(r); - eStructure.addSrcSide(new Reference(thisObjectId, fieldArray.getId(), - methodExecution.getThisClassName(), fieldArray.getActualType())); - srcObject = thisObj; - isSrcSide = true; - } else { - eStructure.addDstSide(r); - eStructure.addDstSide(new Reference(thisObjectId, fieldArray.getId(), - methodExecution.getThisClassName(), fieldArray.getActualType())); - dstObject = thisObj; - isSrcSide = false; - } - } - } - if (trackingObj.getActualType() != null && trackingObj.getActualType().startsWith("[L")) { - // �ǂ��ɂ����‚���Ȃ������ꍇ�A�T���Ă���̂��z��^�Ȃ�΁A���̃��\�b�h���Ő������ꂽ���̂ƍl���� - objList.remove(objectId); - if (isSrcSide2) { - eStructure.addSrcSide(new Reference(thisObjectId, trackingObj.getId(), - methodExecution.getThisClassName(), trackingObj.getActualType())); - srcObject = thisObj; - isSrcSide = true; - } else { - eStructure.addDstSide(new Reference(thisObjectId, trackingObj.getId(), - methodExecution.getThisClassName(), trackingObj.getActualType())); - dstObject = thisObj; - isSrcSide = false; - } - } - } - } - } - } - if (existsInAnArgument) { - // ������1�‚ł��ǐՑΏۂ����݂����ꍇ - if (existsInFields > 0 || isTrackingThis) { - // this�I�u�W�F�N�g��ǐՒ��̏ꍇ - if (!Trace.isNull(thisObjectId)) { - objList.add(thisObjectId); // ����ɒT������ꍇ�A��U��菜���� thisObject �𕜊� - } else { - objList.add(null); // ������static�Ăяo���������ꍇ�A����ȏ�ǐՂ��Ȃ� - } - } -// if (existsInFields > 0) { -// // �t�B�[���h��R���Ɏ��ƒI�u�W�F�N�g�����݂����ꍇ -// if (isSrcSide) { -// srcObject = thisObj; -// } else { -// dstObject = thisObj; -// } -// } - if (tracePoint.isValid()) { - finalCount = 0; - return callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� - } - } - - for (int i = 0; i < objList.size(); i++) { - objList.remove(null); - } - if (objList.isEmpty()) { - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(true); - } else { - // �R���������ł��Ȃ����� - if (!methodExecution.isStatic()) { - finalCount++; - if (finalCount <= LOST_DECISION_EXTENSION) { - // final�ϐ����Q�Ƃ��Ă���ꍇ�R���������ł��Ȃ��”\��������̂ŁA�ǐՂ������I�������P�\���Ԃ�݂��� - if (tracePoint.isValid()) { - MethodExecution c = callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� - if (((DeltaAugmentationInfo)c.getAugmentation()).isCoodinator()) { - methodExecution = c; // �ǐՂ𑱂������ʃR�[�f�B�l�[�^�����‚����� - } - } - } else if (thisObj.getActualType().contains("$")) { - // �����������܂��͖����N���X�̏ꍇ�A���������I�u�W�F�N�g���O�����\�b�h�̓���final�ϐ�����擾�����Ƃ݂Ȃ��A����Ɏ����̒��̃t�B�[���h�̈��Ƃ݂Ȃ� - for (int i = objList.size() - 1; i >= 0; i--) { - String objectId = objList.get(i); - if (objectId != null) { - ObjectReference trackingObj = new ObjectReference(objectId); - boolean isSrcSide2 = true; - trackingObj = null; - if (objectId.equals(srcObject.getId())) { - isSrcSide2 = true; - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - isSrcSide2 = false; - trackingObj = dstObject; - } - if (trackingObj != null) { - r = new Reference(thisObjectId, trackingObj.getId(), - methodExecution.getThisClassName(), trackingObj.getActualType()); - r.setFinalLocal(true); - if (isSrcSide2) { - eStructure.addSrcSide(r); - srcObject = thisObj; - isSrcSide = true; - } else { - eStructure.addDstSide(r); - dstObject = thisObj; - isSrcSide = false; - } - existsInFields++; - objList.remove(objectId); - } - } - } - } - } - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(false); - } - finalCount = 0; - return methodExecution; - } - - /** - * �f���^���o�A���S���Y���̌Ăяo����T������(�ċA�Ăяo���ɂȂ��Ă���) - * @param trace ��͑Ώۃg���[�X - * @param methodExecution �T�����郁�\�b�h���s - * @param objList �ǐՒ��̃I�u�W�F�N�g - * @param isStatic�@�ÓI���\�b�h���ۂ� - * @param index�@objList���̂ǂ̃I�u�W�F�N�g��ǐՂ��Ă��̃��\�b�h���s�ɓ����Ă����̂� - * @throws TraceFileException - */ - protected void calleeSearch(Trace trace, TracePoint tracePoint, ArrayList objList, Boolean isStatic, int index, IAliasCollector aliasCollector) { - MethodExecution methodExecution = tracePoint.getMethodExecution(); - Boolean isResolved = false; - String objectId = objList.get(index); // calleeSearch() �ł͒ǐՑΏۂ̃I�u�W�F�N�g�͈�‚����A��objList��index�Ԗڂ̗v�f�ȊO�ύX���Ă͂����Ȃ� - String thisObjectId = methodExecution.getThisObjId(); - ArrayList fieldArrays = new ArrayList(); - ArrayList fieldArrayElements = new ArrayList(); - ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), - Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), - Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(false); // ��{�I��getter�Ăяo���̂͂������A���� - ArrayList argments = methodExecution.getArguments(); - ObjectReference trackingObj = null; - //static���o�R�����null�������Ă��鎞������ - if (objectId != null) { - String returnType = Trace.getReturnType(methodExecution.getSignature()); - if (objectId.equals(srcObject.getId())) { - trackingObj = srcObject; - trackingObj.setCalleeType(returnType); - } else if(objectId.equals(dstObject.getId())) { - trackingObj = dstObject; - trackingObj.setCalleeType(returnType); - } else { - trackingObj = new ObjectReference(objectId, null, returnType); - } - - Reference r; - // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch�Ăяo�� - do { - if (!tracePoint.isValid()) break; - Statement statement = tracePoint.getStatement(); - // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� - if (statement instanceof FieldAccess) { - FieldAccess fs = (FieldAccess)statement; - if (objectId != null && objectId.equals(fs.getValueObjId())) { - String ownerObjectId = fs.getContainerObjId(); - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ - if (objectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(thisObj, srcObject)); - srcObject = thisObj; - trackingObj = srcObject; - } else if(objectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(thisObj, dstObject)); - dstObject = thisObj; - trackingObj = dstObject; - } - if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = thisObjectId; - objList.set(index, objectId); - } else { - // ���ڎQ�Ƃ̏ꍇ - if (objectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(ownerObjectId, objectId, - fs.getContainerClassName(), srcObject.getActualType())); - srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - trackingObj = srcObject; - } else if(objectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(ownerObjectId, objectId, - fs.getContainerClassName(), dstObject.getActualType())); - dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - trackingObj = dstObject; - } - if (Trace.isNull(ownerObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = ownerObjectId; - objList.set(index, objectId); - } - isResolved = true; - } else { - // �I�u�W�F�N�g�̗R�������ڌ��‚���Ȃ������ꍇ�ł��A�����ꂩ�̔z��̗v�f�ɗR�����Ă���”\�������� - String refObjType = fs.getValueClassName(); - if (refObjType.startsWith("[L")) { - // �Q�Ƃ����t�B�[���h���z��̏ꍇ - if ((trackingObj.getActualType() != null && refObjType.endsWith(trackingObj.getActualType() + ";")) - || (trackingObj.getCalleeType() != null && refObjType.endsWith(trackingObj.getCalleeType() + ";")) - || (trackingObj.getCallerType() != null && refObjType.endsWith(trackingObj.getCallerType() + ";"))) { - // �z��̗v�f�̕����ǐՒ��̃I�u�W�F�N�g�̌^�ƈ�v�����ꍇ - String ownerObjectId = fs.getContainerObjId(); - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ�i���ɗR���̉”\�����Ȃ��Ƃ킩�������_�ŁA���̔z��̗v�f�ɗR�����Ă�����̂Ɛ�������B�j - fieldArrays.add(new ObjectReference(fs.getValueObjId(), refObjType)); - fieldArrayElements.add(trackingObj); - } else { - // ���ڎQ�Ƃ̏ꍇ(�{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u��������ׂ������A - // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� - // ��蒼��������B) - } - } - } - } - } else if (statement instanceof MethodInvocation) { - // �߂�l - MethodExecution childMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); - ObjectReference ret = childMethodExecution.getReturnValue(); - if (ret != null && objectId != null && objectId.equals(ret.getId())) { - childMethodExecution.setAugmentation(new DeltaAugmentationInfo()); - ((DeltaAugmentationInfo)childMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); - TracePoint childTracePoint = tracePoint.duplicate(); - childTracePoint.stepBackNoReturn(); - calleeSearch(trace, childTracePoint, objList, childMethodExecution.isStatic(), index, aliasCollector); // �Ăяo���������ɒT�� - if (childMethodExecution.isConstructor()) { - // �R���X�g���N�^�Ăяo���������ꍇ - if (objectId.equals(srcObject.getId())) { - r = new Reference(thisObj, srcObject); - r.setCreation(true); - eStructure.addSrcSide(r); - srcObject = thisObj; - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - r = new Reference(thisObj, dstObject); - r.setCreation(true); - eStructure.addDstSide(r); - dstObject = thisObj; - trackingObj = dstObject; - } - if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = thisObjectId; - objList.set(index, objectId); - isResolved = true; - isLost = false; - continue; - } - objectId = objList.get(index); - if (objectId == null) { - // static�Ăяo���̖߂�l�������ꍇ�i���Ԃ�j - trackingObj = null; - isResolved = true; - } else if (objectId.equals(srcObject.getId())) { - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - trackingObj = dstObject; - } - if (isLost) { - checkList.add(objList.get(index)); - isLost = false; - } - } else { - // �I�u�W�F�N�g�̗R�������ڌ��‚���Ȃ������ꍇ�ł��A�ǂ����̔z��̗v�f�ɗR�����Ă���”\�������� - String retType = ret.getActualType(); - if (retType.startsWith("[L")) { - // �߂�l���z��̏ꍇ - if ((trackingObj.getActualType() != null && retType.endsWith(trackingObj.getActualType() + ";")) - || (trackingObj.getCalleeType() != null && retType.endsWith(trackingObj.getCalleeType() + ";")) - || (trackingObj.getCallerType() != null && retType.endsWith(trackingObj.getCallerType() + ";"))) { - // �{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u�������āA�Ăяo�����T�����ׂ������A - // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� - // ��蒼��������B - } - } - } - } - } while (tracePoint.stepBackOver()); - - //�����T�� - if (argments.contains(new ObjectReference(objectId))) { - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(true); // �������K�v? - isResolved = true; - } - } - - //�R���N�V�����^�Ή� - Reference r; - if (methodExecution.isCollectionType()) { - if (objectId != null) { - // �R���N�V�����^�̏ꍇ�A�����ԁX�̗v�f�𒼐ڕێ����Ă���Ɖ��肷�� - if (objectId.equals(srcObject.getId())) { - r = new Reference(thisObj, srcObject); - r.setCollection(true); - eStructure.addSrcSide(r); - srcObject = thisObj; - } else if(objectId.equals(dstObject.getId())) { - r = new Reference(thisObj, dstObject); - r.setCollection(true); - eStructure.addDstSide(r); - dstObject =thisObj; - } - } - objList.set(index, methodExecution.getThisObjId()); - isResolved = true; // �K�v�Ȃ̂ł�? - } - - if (!isResolved && objectId != null) { - // �R�����ǂ��ɂ����‚���Ȃ����� - boolean isSrcSide = true; - if (objectId.equals(srcObject.getId())) { - isSrcSide = true; - } else if (objectId.equals(dstObject.getId())) { - isSrcSide = false; - } - if (trackingObj != null) { - // �܂��z������̗v�f��R���Ƃ��ċ^��(�������D��) - for (int i = 0; i < argments.size(); i++) { - ObjectReference argArray = argments.get(i); - if (argArray.getActualType().startsWith("[L") - && ((trackingObj.getActualType() != null && argArray.getActualType().endsWith(trackingObj.getActualType() + ";")) - || (trackingObj.getCalleeType() != null && argArray.getActualType().endsWith(trackingObj.getCalleeType() + ";")) - || (trackingObj.getCallerType() != null && argArray.getActualType().endsWith(trackingObj.getCallerType() + ";")))) { - // �^����v������z������̗v�f��R���Ƃ݂Ȃ� - isResolved = true; - objList.set(index, argArray.getId()); // �ǐՑΏۂ�z��v�f����z��ɒu������ - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(argArray.getId())); - r = new Reference(argArray.getId(), trackingObj.getId(), - argArray.getActualType(), trackingObj.getActualType()); - r.setArray(true); - if (isSrcSide) { - eStructure.addSrcSide(r); - srcObject = new ObjectReference(argArray.getId(), argArray.getActualType()); - } else { - eStructure.addDstSide(r); - dstObject = new ObjectReference(argArray.getId(), argArray.getActualType()); - } - objectId = null; - break; - } - } - if (objectId != null) { - // ���ɔz��t�B�[���h�̗v�f��R���Ƃ��ċ^��(�t�B�[���h�͈�������) - int indArg = fieldArrayElements.indexOf(trackingObj); - if (indArg != -1) { - // �^����v���Ă�̂Ŕz��t�B�[���h�̗v�f��R���Ƃ݂Ȃ� - isResolved = true; - ObjectReference fieldArray = fieldArrays.get(indArg); - objList.set(index, thisObjectId); // �ǐՑΏۂ�this�ɒu������ - r = new Reference(fieldArray.getId(), trackingObj.getId(), - fieldArray.getActualType(), trackingObj.getActualType()); - r.setArray(true); - if (isSrcSide) { - eStructure.addSrcSide(r); - eStructure.addSrcSide(new Reference(thisObjectId, fieldArray.getId(), - methodExecution.getThisClassName(), fieldArray.getActualType())); - srcObject = thisObj; - } else { - eStructure.addDstSide(r); - eStructure.addDstSide(new Reference(thisObjectId, fieldArray.getId(), - methodExecution.getThisClassName(), fieldArray.getActualType())); - dstObject = thisObj; - } - } - } - if (trackingObj.getActualType() != null && trackingObj.getActualType().startsWith("[L")) { - // �ǂ��ɂ����‚���Ȃ������ꍇ�A�T���Ă���̂��z��^�Ȃ�΁A���̃��\�b�h���Ő������ꂽ���̂ƍl���� - isResolved = true; - objList.set(index, thisObjectId); // �ǐՑΏۂ�this�ɒu������ - if (isSrcSide) { - eStructure.addSrcSide(new Reference(thisObjectId, trackingObj.getId(), - methodExecution.getThisClassName(), trackingObj.getActualType())); - srcObject = thisObj; - } else { - eStructure.addDstSide(new Reference(thisObjectId, trackingObj.getId(), - methodExecution.getThisClassName(), trackingObj.getActualType())); - dstObject = thisObj; - } - } - } - } - - if (objectId == null && isResolved && !isStatic) { // static �Ăяo������̖߂�l��Ԃ��Ă���ꍇ - objList.set(index, thisObjectId); // ������ǐՂ����� - if (Trace.isNull(srcObject.getId())) { - srcObject = thisObj; - } else if (Trace.isNull(dstObject.getId())) { - dstObject = thisObj; - } - } - - if (isStatic && !isResolved) { // ���͋N���肦�Ȃ�?(get�|�C���g�J�b�g���擾����悤�ɂ�������) - objList.set(index, null); - } - if(!isStatic && !isResolved){ - isLost = true; // final�ϐ�������N���X�ŎQ�Ƃ��Ă���”\�������邪�AcalleeSearch()�͕K���Ăяo�����ɕ��A���Ă����̂ŁA�����ł͉������Ȃ� - } - } - - /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) - * @param targetRef �ΏۂƂȂ�Q�� - * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) - * @return ���o���� - */ - public ExtractedStructure extract(Reference targetRef, TracePoint before) { - return extract(targetRef, before, defaultAliasCollector); - } - - /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) - * @param targetRef �ΏۂƂȂ�Q�� - * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) - * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i - * @return ���o���� - */ - public ExtractedStructure extract(Reference targetRef, TracePoint before, IAliasCollector aliasCollector) { - TracePoint creationTracePoint; - if (targetRef.isArray()) { - // srcId �̔z��� dstId ���������Ă���”\�������郁�\�b�h���s���擾�i�z���p�̏����j - creationTracePoint = trace.getArraySetTracePoint(targetRef, before); - } else if (targetRef.isCollection()) { - // srcId �̃R���N�V�����^�I�u�W�F�N�g�� dstId ���n����Ă��郁�\�b�h���s���擾�i�R���N�V�����^��p�̏����j - creationTracePoint = trace.getCollectionAddTracePoint(targetRef, before); - } else if (targetRef.isFinalLocal()) { - // srcId �̓����܂��͖����N���X�̃C���X�^���X�� final local �ϐ��ɑ������Ă��� dstId �� �I�u�W�F�N�g���n���ꂽ�”\�������郁�\�b�h���s���擾�ifinal local�̋^��������ꍇ�̏����j - creationTracePoint = trace.getCreationTracePoint(targetRef.getSrcObject(), before); - targetRef = new Reference(creationTracePoint.getMethodExecution().getThisObjId(), targetRef.getDstObjectId(), creationTracePoint.getMethodExecution().getThisClassName(), targetRef.getDstClassName()); - } else { - // �I�u�W�F�N�g�ԎQ�� r ���������ꂽ���\�b�h���s���擾�i�ʏ�j - creationTracePoint = trace.getFieldUpdateTracePoint(targetRef, before); - } - if (creationTracePoint == null) { - return null; - } - return extractSub(creationTracePoint, targetRef, aliasCollector); - } - - /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) - * @param creationTracePoint �I�u�W�F�N�g�ԎQ�Ɛ����g���[�X�|�C���g(�t�B�[���h�ւ̑��) - * @return ���o���� - */ - public ExtractedStructure extract(TracePoint creationTracePoint) { - creationTracePoint = creationTracePoint.duplicate(); - Statement statement = creationTracePoint.getStatement(); - if (statement instanceof FieldUpdate) { - Reference targetRef = ((FieldUpdate)statement).getReference(); - return extractSub(creationTracePoint, targetRef, defaultAliasCollector); - } else { - return null; - } - } - - /** - * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) - * @param creationTracePoint �I�u�W�F�N�g�ԎQ�Ɛ����g���[�X�|�C���g(�t�B�[���h�ւ̑��) - * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i - * @return ���o���� - */ - public ExtractedStructure extract(TracePoint creationTracePoint, IAliasCollector aliasCollector) { - creationTracePoint = creationTracePoint.duplicate(); - Statement statement = creationTracePoint.getStatement(); - if (statement instanceof FieldUpdate) { - Reference targetRef = ((FieldUpdate)statement).getReference(); - return extractSub(creationTracePoint, targetRef, aliasCollector); - } else { - return null; - } - } - - private ExtractedStructure extractSub(TracePoint creationTracePoint, Reference targetRef, IAliasCollector aliasCollector) { - eStructure = new ExtractedStructure(); - ArrayList objList = new ArrayList(); - srcObject = targetRef.getSrcObject(); - dstObject = targetRef.getDstObject(); -if (DEBUG1) { - System.out.println("extract delta of:" + targetRef.getSrcObject().getActualType() + "(" + targetRef.getSrcObjectId() + ")" + " -> " + targetRef.getDstObject().getActualType() + "(" + targetRef.getDstObjectId() + ")"); -} - if (!Trace.isNull(targetRef.getSrcObjectId())) { - objList.add(targetRef.getSrcObjectId()); - } else { - objList.add(null); - } - if (!Trace.isNull(targetRef.getDstObjectId())) { - objList.add(targetRef.getDstObjectId()); - } else { - objList.add(null); - } - return extractSub2(creationTracePoint, objList, aliasCollector); - } - - public ExtractedStructure extract(TracePoint tracePoint, ObjectReference argObj) { - return extract(tracePoint, argObj, defaultAliasCollector); - } - - public ExtractedStructure extract(TracePoint tracePoint, ObjectReference argObj, IAliasCollector aliasCollector) { - MethodExecution methodExecution = tracePoint.getMethodExecution(); - eStructure = new ExtractedStructure(); - ArrayList objList = new ArrayList(); - String thisObjectId = methodExecution.getThisObjId(); - objList.add(thisObjectId); - objList.add(argObj.getId()); - srcObject = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), - Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - dstObject = argObj; -if (DEBUG1) { - System.out.println("extract delta of:" + methodExecution.getSignature() + " -> " + argObj.getActualType() + "(" + argObj.getId() + ")"); -} - return extractSub2(tracePoint, objList, aliasCollector); - } - - private ExtractedStructure extractSub2(TracePoint creationTracePoint, ArrayList objList, IAliasCollector aliasCollector) { - eStructure.setCreationMethodExecution(creationTracePoint.getMethodExecution()); - MethodExecution coordinator = callerSearch(trace, creationTracePoint, objList, null, aliasCollector); - eStructure.setCoordinator(coordinator); -if (DEBUG2) { - if (((DeltaAugmentationInfo)coordinator.getAugmentation()).isCoodinator()) { - System.out.println("Coordinator"); - } else { - System.out.println("Warning"); - } - System.out.println("coordinator:" + coordinator.getSignature()); - System.out.println("srcSide:"); - for (int i = 0; i < eStructure.getDelta().getSrcSide().size(); i++) { - Reference ref = eStructure.getDelta().getSrcSide().get(i); - if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { - System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); - } - } - System.out.println("dstSide:"); - for (int i = 0; i < eStructure.getDelta().getDstSide().size(); i++) { - Reference ref = eStructure.getDelta().getDstSide().get(i); - if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { - System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); - } - } - System.out.println("overCoordinator:"); - MethodExecution parent = coordinator.getParent(); - while (parent != null) { - System.out.println("\t" + parent.getSignature()); - parent = parent.getParent(); - } -} - return eStructure; - } - - /** - * ���ۂ̎Q�ƌ��ƎQ�Ɛ�̃I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) - * @param srcObj ��������ɂ���Q�ƌ��I�u�W�F�N�g - * @param dstObj ��������ɂ���Q�Ɛ�I�u�W�F�N�g - * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) - * @return�@���o���� - */ - public ExtractedStructure extract(Object srcObj, Object dstObj, TracePoint before) { - return extract(srcObj, dstObj, before, defaultAliasCollector); - } - - /** - * �Q�ƌ��ƎQ�Ɛ�̃I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) - * @param srcObj ��������ɂ���Q�ƌ��I�u�W�F�N�g - * @param dstObj ��������ɂ���Q�Ɛ�I�u�W�F�N�g - * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) - * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i - * @return�@���o���� - */ - public ExtractedStructure extract(Object srcObj, Object dstObj, TracePoint before, IAliasCollector aliasCollector) { - Reference targetRef = new Reference(Integer.toString(System.identityHashCode(srcObj)), Integer.toString(System.identityHashCode(dstObj)), null, null); - return extract(targetRef, before, aliasCollector); - } - - /** - * ���\�b�h���s���̃g���[�X�|�C���g�Ǝ��ۂ̎Q�Ɛ�I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) - * @param tracePoint ���\�b�h���s���̃g���[�X�|�C���g - * @param arg ��������ɂ���Q�Ɛ�I�u�W�F�N�g(���[�J���ϐ�������ɂ��Q�Ɛ�) - * @return ���o���� - */ - public ExtractedStructure extract(TracePoint tracePoint, Object arg) { - return extract(tracePoint, arg, defaultAliasCollector); - } - - /** - * ���\�b�h���s���̃g���[�X�|�C���g�Ǝ��ۂ̎Q�Ɛ�I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) - * @param tracePoint ���\�b�h���s���̃g���[�X�|�C���g - * @param arg ��������ɂ���Q�Ɛ�I�u�W�F�N�g(���[�J���ϐ�������ɂ��Q�Ɛ�) - * @return ���o���� - */ - public ExtractedStructure extract(TracePoint tracePoint, Object arg, IAliasCollector aliasCollector) { - ObjectReference argObj = new ObjectReference(Integer.toString(System.identityHashCode(arg))); - return extract(tracePoint, argObj, aliasCollector); - } - - /** - * �w�肵���X���b�h��Ō��ݎ��s���̃��\�b�h���s���擾����(�I�����C����͗p) - * @param thread �ΏۃX���b�h - * @return thread ��Ō��ݎ��s���̃��\�b�h���s - */ - public MethodExecution getCurrentMethodExecution(Thread thread) { - return trace.getCurrentMethodExecution(thread); - } - - /** - * methodSignature �ɑO����v���郁�\�b�h�������ƒ��\�b�h�̍Ō�̎��s - * @param methodSignature ���\�b�h��(�O����v�Ō�������) - * @return �Y������Ō�̃��\�b�h���s - */ - public MethodExecution getLastMethodExecution(String methodSignature) { - return trace.getLastMethodExecution(methodSignature); - } - - /** - * methodSignature �ɑO����v���郁�\�b�h�������ƒ��\�b�h�� before �ȑO�̍Ō�̎��s - * @param methodSignature ���\�b�h��(�O����v�Ō�������) - * @param before�@�T���J�n�g���[�X�|�C���g(������ȑO��T��) - * @return�@�Y������Ō�̃��\�b�h���s - */ - public MethodExecution getLastMethodExecution(String methodSignature, TracePoint before) { - return trace.getLastMethodExecution(methodSignature, before); - } - - public ArrayList getMethodExecutions(String methodSignature) { - return trace.getMethodExecutions(methodSignature); - } - -// public ExtractedStructure extract(MethodExecution caller, MethodExecution callee) { -// eStructure = new ExtractedStructure(); -// ArrayList objList = new ArrayList(); -// String thisObjectId = caller.getThisObjId(); -// objList.add(thisObjectId); -// objList.add(callee.getThisObjId()); -// srcObject = new ObjectReference(thisObjectId, caller.getThisClassName(), -// Trace.getDeclaringType(caller.getSignature(), caller.isConstractor()), Trace.getDeclaringType(caller.getCallerSideSignature(), caller.isConstractor())); -// dstObject = new ObjectReference(callee.getThisObjId(), callee.getThisClassName(), -// Trace.getDeclaringType(callee.getSignature(), callee.isConstractor()), Trace.getDeclaringType(callee.getCallerSideSignature(), callee.isConstractor())); -//if (DEBUG1) { -// System.out.println("extract delta of:" + caller.getSignature() + " -> " + callee.getSignature()); -//} -// -// caller = new MethodExecution(caller); // ��͗p�p�����[�^���������������̂��g�p���� -// eStructure.setCreationMethodExecution(caller); -// MethodExecution coordinator = callerSearch(trace, caller, objList, null); -// eStructure.setCoordinator(coordinator); -//if (DEBUG2) { -// if (coordinator.isCoodinator()) { -// System.out.println("Coordinator"); -// } else { -// System.out.println("Warning"); -// } -// System.out.println("coordinator:" + coordinator.getSignature()); -// System.out.println("srcSide:"); -// for (int i = 0; i < eStructure.getDelta().getSrcSide().size(); i++) { -// Reference ref = eStructure.getDelta().getSrcSide().get(i); -// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { -// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); -// } -// } -// System.out.println("dstSide:"); -// for (int i = 0; i < eStructure.getDelta().getDstSide().size(); i++) { -// Reference ref = eStructure.getDelta().getDstSide().get(i); -// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { -// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); -// } -// } -// System.out.println("overCoordinator:"); -// MethodExecution parent = coordinator.getParent(); -// while (parent != null) { -// System.out.println("\t" + parent.getSignature()); -// parent = parent.getParent(); -// } -//} -// return eStructure; -// } -// -// -// /** -// * ���\�b�h�̈����Ƃ��ăI�u�W�F�N�g���Q�Ƃ����ꍇ�̃f���^�𒊏o���� -// * @param caller �Q�ƌ��̃��\�b�h -// * @param argObj �����Ƃ��ĎQ�Ƃ����I�u�W�F�N�g -// * @return�@���o���� -// */ -// public ExtractedStructure extract(MethodExecution caller, ObjectReference argObj) { -// eStructure = new ExtractedStructure(); -// ArrayList objList = new ArrayList(); -// String thisObjectId = caller.getThisObjId(); -// objList.add(thisObjectId); -// objList.add(argObj.getId()); -// srcObject = new ObjectReference(thisObjectId, caller.getThisClassName(), -// Trace.getDeclaringType(caller.getSignature(), caller.isConstractor()), Trace.getDeclaringType(caller.getCallerSideSignature(), caller.isConstractor())); -// dstObject = argObj; -//if (DEBUG1) { -// System.out.println("extract delta of:" + caller.getSignature() + " -> " + argObj.getActualType() + "(" + argObj.getId() + ")"); -//} -// -// caller = new MethodExecution(caller); // ��͗p�p�����[�^���������������̂��g�p���� -// eStructure.setCreationMethodExecution(caller); -// MethodExecution coordinator = callerSearch(trace, caller, objList, null); -// eStructure.setCoordinator(coordinator); -//if (DEBUG2) { -// if (coordinator.isCoodinator()) { -// System.out.println("Coordinator"); -// } else { -// System.out.println("Warning"); -// } -// System.out.println("coordinator:" + coordinator.getSignature()); -// System.out.println("srcSide:"); -// for (int i = 0; i < eStructure.getDelta().getSrcSide().size(); i++) { -// Reference ref = eStructure.getDelta().getSrcSide().get(i); -// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { -// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); -// } -// } -// System.out.println("dstSide:"); -// for (int i = 0; i < eStructure.getDelta().getDstSide().size(); i++) { -// Reference ref = eStructure.getDelta().getDstSide().get(i); -// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { -// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); -// } -// } -// System.out.println("overCoordinator:"); -// MethodExecution parent = coordinator.getParent(); -// while (parent != null) { -// System.out.println("\t" + parent.getSignature()); -// parent = parent.getParent(); -// } -//} -// return eStructure; -// } -} +package org.ntlab.deltaExtractor; + +import java.util.ArrayList; + +import org.ntlab.trace.FieldAccess; +import org.ntlab.trace.FieldUpdate; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.MethodInvocation; +import org.ntlab.trace.ObjectReference; +import org.ntlab.trace.Reference; +import org.ntlab.trace.Statement; +import org.ntlab.trace.Trace; +import org.ntlab.trace.TracePoint; + +/** + * �f���^���o�A���S���Y��(�z��ւ̃A�N�Z�X�𐄑�����]���̃o�[�W����) + * extract(...)���\�b�h�Q�Œ��o����Bcd + * + * @author Nitta + * + */ +public class DeltaExtractor { + protected static final int LOST_DECISION_EXTENSION = 0; // ��{�� 0 �ɐݒ�Bfinal�ϐ��̒ǐՃA���S���Y���̕s��C����͕s�v�̂͂��B + protected ArrayList data = new ArrayList(); + protected ArrayList objList = new ArrayList(2); + protected ArrayList methodList = new ArrayList(); + protected ExtractedStructure eStructure = new ExtractedStructure(); + protected ObjectReference srcObject = null; + protected ObjectReference dstObject = null; + protected String returnValue; + protected String threadNo; + protected boolean isLost = false; + protected ArrayList checkList = new ArrayList(); + protected Trace trace = null; + protected int finalCount = 0; // final�ϐ������o�ł��Ȃ��”\��������̂ŁA�R���̉������ł��Ȃ������ꍇ�ł����΂炭�ǐՂ��‚Â��� + + protected static final boolean DEBUG1 = true; + protected static final boolean DEBUG2 = true; + protected final IAliasCollector defaultAliasCollector = new IAliasCollector() { + @Override + public void changeTrackingObject(String from, String to, boolean isSrcSide) { + } + @Override + public void addAlias(Alias alias) { + } + }; + + public DeltaExtractor(String traceFile) { + trace = new Trace(traceFile); + } + + public DeltaExtractor(Trace trace) { + this.trace = trace; + } + +// public MethodExecution getMethodExecution(Reference createdReference, MethodExecution before) { +// return trace.getMethodExecution(createdReference, before); +// } +// +// public MethodExecution getMethodExecution(String methodSignature) { +// return trace.getMethodExecution(methodSignature); +// } +// +// public MethodExecution getMethodExecutionBackwardly(String methodSignature) { +// return trace.getMethodExecutionBackwardly(methodSignature); +// } +// +// public MethodExecution getCollectionTypeMethodExecution(Reference r, MethodExecution before) { +// return trace.getCollectionTypeMethodExecution(r, before); +// } +// +// public MethodExecution getArraySetMethodExecution(Reference r, MethodExecution before) { +// return trace.getArraySetMethodExecution(r, before); +// } +// +// public CallTree getLastCallTree(ArrayList refs, +// ArrayList colls, +// ArrayList arrys, +// int endLine, +// Reference[] lastRef) throws TraceFileException { +// return trace.getLastCallTree(refs, colls, arrys, endLine, lastRef); +// } + + /** + * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j + * @param trace�@��͑Ώۃg���[�X + * @param methodExecution �T�����郁�\�b�h���s + * @param objList�@�ǐՒ��̃I�u�W�F�N�g + * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s + * @return ���‚������R�[�f�B�l�[�^ + * @throws TraceFileException + */ + protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution) { + return callerSearch(trace, tracePoint, objList, childMethodExecution, defaultAliasCollector); + } + + /** + * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j + * @param trace�@��͑Ώۃg���[�X + * @param methodExecution �T�����郁�\�b�h���s + * @param objList�@�ǐՒ��̃I�u�W�F�N�g + * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s + * @return ���‚������R�[�f�B�l�[�^ + * @throws TraceFileException + */ + protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution, IAliasCollector aliasCollector) { + MethodExecution methodExecution = tracePoint.getMethodExecution(); + methodExecution.setAugmentation(new DeltaAugmentationInfo()); + eStructure.createParent(methodExecution); + String thisObjectId = methodExecution.getThisObjId(); + ArrayList removeList = new ArrayList(); // �ǐՂ��Ă���I�u�W�F�N�g���ō폜�ΏۂƂȂ��Ă������ + ArrayList creationList = new ArrayList(); // ���̃��\�b�h���s���ɐ������ꂽ�I�u�W�F�N�g + int existsInFields = 0; // ���̃��\�b�h���s���Ńt�B�[���h�ɗR�����Ă���I�u�W�F�N�g�̐�(1�ȏ�Ȃ炱�̃��\�b�h���s����this�Ɉˑ�) + boolean isTrackingThis = false; // �Ăяo�����this�Ɉˑ����� + boolean isSrcSide = true; // �Q�ƌ����Q�Ɛ�̂�����̑��̃I�u�W�F�N�g�̗R�������ǂ���this�I�u�W�F�N�g�ɓ��B������? + ArrayList fieldArrays = new ArrayList(); + ArrayList fieldArrayElements = new ArrayList(); + ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), + Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); + + if (childMethodExecution == null) { + // �T���J�n���͈�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + + if (childMethodExecution != null && objList.contains(childMethodExecution.getThisObjId())) { + // �Ăяo�����this�Ɉˑ����� + if (thisObjectId.equals(childMethodExecution.getThisObjId())) { + // �I�u�W�F�N�g���Ăяo���̂Ƃ��݈̂�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + } + + if (childMethodExecution != null && childMethodExecution.isConstructor()) { + // �Ăяo���悪�R���X�g���N�^�������ꍇ + int newIndex = objList.indexOf(childMethodExecution.getThisObjId()); + if (newIndex != -1) { + // �Ăяo���悪�ǐՑΏۂ̃R���X�g���N�^��������field�Ɠ��l�ɏ��� + removeList.add(childMethodExecution.getThisObjId()); + existsInFields++; + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + } + } + + if (childMethodExecution != null && Trace.getMethodName(childMethodExecution.getSignature()).startsWith("access$")) { + // �G���N���[�W���O�C���X�^���X�ɑ΂��郁�\�b�h�Ăяo���������ꍇ + String enclosingObj = childMethodExecution.getArguments().get(0).getId(); // �G���N���[�W���O�C���X�^���X�͑������ɓ����Ă���炵�� + int encIndex = objList.indexOf(enclosingObj); + if (encIndex != -1) { + // thisObject �ɒu����������Afield�Ɠ��l�ɏ��� + removeList.add(enclosingObj); + existsInFields++; + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + } + } + + // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch���ċA�Ăяo�� + while (tracePoint.stepBackOver()) { + Statement statement = tracePoint.getStatement(); + // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� + if (statement instanceof FieldAccess) { + FieldAccess fs = (FieldAccess)statement; + String refObjectId = fs.getValueObjId(); + int index = objList.indexOf(refObjectId); + if (index != -1) { + String ownerObjectId = fs.getContainerObjId(); + if (ownerObjectId.equals(thisObjectId)) { + // �t�B�[���h�Q�Ƃ̏ꍇ + removeList.add(refObjectId); + existsInFields++; // set�������get�����o���Ă���”\�������� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + } else { + // ���ڎQ�Ƃ̏ꍇ + if (refObjectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(ownerObjectId, refObjectId, + fs.getContainerClassName(), srcObject.getActualType())); + srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + } else if(refObjectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(ownerObjectId, refObjectId, + fs.getContainerClassName(), dstObject.getActualType())); + dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + } + objList.set(index, ownerObjectId); + } + } else { + // �ŏI�I�ɃI�u�W�F�N�g�̗R�������‚���Ȃ������ꍇ�ɁA�����ŎQ�Ƃ����z������̗v�f�ɗR�����Ă���”\�������� + String refObjType = fs.getValueClassName(); + if (refObjType.startsWith("[L")) { + // �Q�Ƃ����t�B�[���h���z��̏ꍇ + ObjectReference trackingObj = null; + if ((srcObject.getActualType() != null && refObjType.endsWith(srcObject.getActualType() + ";")) + || (srcObject.getCalleeType() != null && refObjType.endsWith(srcObject.getCalleeType() + ";")) + || (srcObject.getCallerType() != null && refObjType.endsWith(srcObject.getCallerType() + ";"))) { + trackingObj = srcObject; + } else if ((dstObject.getActualType() != null && refObjType.endsWith(dstObject.getActualType() + ";")) + || (dstObject.getCalleeType() != null && refObjType.endsWith(dstObject.getCalleeType() + ";")) + || (dstObject.getCallerType() != null && refObjType.endsWith(dstObject.getCallerType() + ";"))) { + trackingObj = dstObject; + } + if (trackingObj != null) { + // �ǐՒ��̃I�u�W�F�N�g�ɁA�z��v�f�Ɠ����^�����ƒI�u�W�F�N�g�����݂���ꍇ + String ownerObjectId = fs.getContainerObjId(); + if (ownerObjectId.equals(thisObjectId)) { + // �t�B�[���h�Q�Ƃ̏ꍇ�i���ɗR���̉”\�����Ȃ��Ƃ킩�������_�ŁA���̔z��̗v�f�ɗR�����Ă�����̂Ɛ�������B�j + fieldArrays.add(new ObjectReference(refObjectId, refObjType)); + fieldArrayElements.add(trackingObj); + } else { + // ���ڎQ�Ƃ̏ꍇ(�{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u��������ׂ������A + // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� + // ��蒼��������B) + } + } + } + } + } else if (statement instanceof MethodInvocation) { + MethodExecution prevChildMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); + if (!prevChildMethodExecution.equals(childMethodExecution)) { + // �߂�l + ObjectReference ret = prevChildMethodExecution.getReturnValue(); + if (ret != null) { + int retIndex = -1; + retIndex = objList.indexOf(ret.getId()); + if (retIndex != -1) { + // �߂�l���R�������� + prevChildMethodExecution.setAugmentation(new DeltaAugmentationInfo()); + if (prevChildMethodExecution.isConstructor()) { + // �ǐՑΏۂ�constractor���Ă�ł�����(�I�u�W�F�N�g�̐�����������)field�Ɠ��l�ɏ��� + String newObjId = ret.getId(); + creationList.add(newObjId); + removeList.add(newObjId); + existsInFields++; + // objList.remove(callTree.getThisObjId()); + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(newObjId)); // �ǐՑΏ� + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setSetterSide(false); // getter�Ăяo���Ɠ��l + continue; + } + String retObj = objList.get(retIndex); + if (removeList.contains(retObj)) { + // ��xget�Ō��o���ăt�B�[���h�Ɉˑ����Ă���Ɣ��f�������{���̗R�����߂�l���������Ƃ����������̂ŁA�t�B�[���h�ւ̈ˑ����L�����Z������ + removeList.remove(retObj); + existsInFields--; + if (existsInFields == 0) { + removeList.remove(thisObjectId); + } + } + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(retObj)); // �ǐՑΏ� + TracePoint prevChildTracePoint = tracePoint.duplicate(); + prevChildTracePoint.stepBackNoReturn(); + calleeSearch(trace, prevChildTracePoint, objList, prevChildMethodExecution.isStatic(), retIndex, aliasCollector); // �Ăяo�����T�� + if (objList.get(retIndex) != null && objList.get(retIndex).equals(prevChildMethodExecution.getThisObjId()) + && thisObjectId.equals(prevChildMethodExecution.getThisObjId())) { + // �Ăяo����Ńt�B�[���h�Ɉˑ����Ă����ꍇ�̏��� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + if (isLost) { + checkList.add(objList.get(retIndex)); + isLost = false; + } + } else { + // �ŏI�I�ɃI�u�W�F�N�g�̗R�������‚���Ȃ������ꍇ�ɁA���̖߂�l�Ŏ擾�����z������̗v�f�ɗR�����Ă���”\�������� + String retType = ret.getActualType(); + if (retType.startsWith("[L")) { + // �߂�l���z��̏ꍇ + if ((srcObject.getActualType() != null && retType.endsWith(srcObject.getActualType() + ";")) + || (srcObject.getCalleeType() != null && retType.endsWith(srcObject.getCalleeType() + ";")) + || (srcObject.getCallerType() != null && retType.endsWith(srcObject.getCallerType() + ";"))) { + retType = srcObject.getActualType(); + } else if ((dstObject.getActualType() != null && retType.endsWith(dstObject.getActualType() + ";")) + || (dstObject.getCalleeType() != null && retType.endsWith(dstObject.getCalleeType() + ";")) + || (dstObject.getCallerType() != null && retType.endsWith(dstObject.getCallerType() + ";"))) { + retType = dstObject.getActualType(); + } else { + retType = null; + } + if (retType != null) { + // �{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u�������āA�Ăяo�����T�����ׂ������A + // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� + // ��蒼��������B + } + } + } + } + } + } + } + // --- ���̎��_�� tracePoint �͌Ăяo�������w���Ă��� --- + + // �R���N�V�����^�Ή� + if (methodExecution.isCollectionType()) { + objList.add(thisObjectId); + } + + // �����̎擾 + ArrayList argments = methodExecution.getArguments(); + + // �����ƃt�B�[���h�ɓ���ID�̃I�u�W�F�N�g������ꍇ��z�� + Reference r; + for (int i = 0; i < removeList.size(); i++) { + String removeId = removeList.get(i); + if (argments.contains(new ObjectReference(removeId))) { + removeList.remove(removeId); // �t�B�[���h�ƈ����̗����ɒǐՑΏۂ����݂����ꍇ�A������D�� + } else if(objList.contains(removeId)) { + // �t�B�[���h�ɂ����Ȃ������ꍇ(�������A�I�u�W�F�N�g�̐������t�B�[���h�Ɠ��l�Ɉ���) + objList.remove(removeId); // �ǐՑΏۂ���O�� + if (!removeId.equals(thisObjectId)) { + // �t�B�[���h�ithis ���� removeId �ւ̎Q�Ɓj���f���^�̍\���v�f�ɂȂ� + if (removeId.equals(srcObject.getId())) { + r = new Reference(thisObj, srcObject); + r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? + eStructure.addSrcSide(r); + srcObject = thisObj; + isSrcSide = true; + } else if (removeId.equals(dstObject.getId())) { + r = new Reference(thisObj, dstObject); + r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? + eStructure.addDstSide(r); + dstObject = thisObj; + isSrcSide = false; + } + } + } + } + // --- ���̎��_�� this ���ǐՑΏۂł������Ƃ��Ă� objList �̒����炢������폜����Ă��� --- + + // �����T�� + boolean existsInAnArgument = false; + for (int i = 0; i < objList.size(); i++) { + String objectId = objList.get(i); + if (objectId != null) { + ObjectReference trackingObj = new ObjectReference(objectId); + if (argments.contains(trackingObj)) { + // �������R�������� + existsInAnArgument = true; + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); + } else { + // �R�����ǂ��ɂ����‚���Ȃ����� + boolean isSrcSide2 = true; + trackingObj = null; + if (objectId.equals(srcObject.getId())) { + isSrcSide2 = true; + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + isSrcSide2 = false; + trackingObj = dstObject; + } + if (trackingObj != null) { + // �܂��z������̗v�f��R���Ƃ��ċ^��(������D��) + for (int j = 0; j < argments.size(); j++) { + ObjectReference argArray = argments.get(j); + if (argArray.getActualType().startsWith("[L") + && (trackingObj.getActualType() != null && (argArray.getActualType().endsWith(trackingObj.getActualType() + ";")) + || (trackingObj.getCalleeType() != null && argArray.getActualType().endsWith(trackingObj.getCalleeType() + ";")) + || (trackingObj.getCallerType() != null && argArray.getActualType().endsWith(trackingObj.getCallerType() + ";")))) { + // �^����v������z������̗v�f��R���Ƃ݂Ȃ� + existsInAnArgument = true; + objList.remove(objectId); + objList.add(argArray.getId()); // �ǐՑΏۂ�z��v�f����z��ɒu������ + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(argArray.getId())); + r = new Reference(argArray.getId(), trackingObj.getId(), + argArray.getActualType(), trackingObj.getActualType()); + r.setArray(true); + if (isSrcSide2) { + eStructure.addSrcSide(r); + srcObject = new ObjectReference(argArray.getId(), argArray.getActualType()); + } else { + eStructure.addDstSide(r); + dstObject = new ObjectReference(argArray.getId(), argArray.getActualType()); + } + objectId = null; + break; + } + } + if (objectId != null) { + // ���ɔz��t�B�[���h�̗v�f��R���Ƃ��ċ^��(�t�B�[���h�͈�������) + int index = fieldArrayElements.indexOf(trackingObj); + if (index != -1) { + // �^����v���Ă�̂Ŕz��t�B�[���h�̗v�f��R���Ƃ݂Ȃ� + ObjectReference fieldArray = fieldArrays.get(index); + existsInFields++; + objList.remove(objectId); + r = new Reference(fieldArray.getId(), trackingObj.getId(), + fieldArray.getActualType(), trackingObj.getActualType()); + r.setArray(true); + if (isSrcSide2) { + eStructure.addSrcSide(r); + eStructure.addSrcSide(new Reference(thisObjectId, fieldArray.getId(), + methodExecution.getThisClassName(), fieldArray.getActualType())); + srcObject = thisObj; + isSrcSide = true; + } else { + eStructure.addDstSide(r); + eStructure.addDstSide(new Reference(thisObjectId, fieldArray.getId(), + methodExecution.getThisClassName(), fieldArray.getActualType())); + dstObject = thisObj; + isSrcSide = false; + } + } + } + if (trackingObj.getActualType() != null && trackingObj.getActualType().startsWith("[L")) { + // �ǂ��ɂ����‚���Ȃ������ꍇ�A�T���Ă���̂��z��^�Ȃ�΁A���̃��\�b�h���Ő������ꂽ���̂ƍl���� + objList.remove(objectId); + if (isSrcSide2) { + eStructure.addSrcSide(new Reference(thisObjectId, trackingObj.getId(), + methodExecution.getThisClassName(), trackingObj.getActualType())); + srcObject = thisObj; + isSrcSide = true; + } else { + eStructure.addDstSide(new Reference(thisObjectId, trackingObj.getId(), + methodExecution.getThisClassName(), trackingObj.getActualType())); + dstObject = thisObj; + isSrcSide = false; + } + } + } + } + } + } + if (existsInAnArgument) { + // ������1�‚ł��ǐՑΏۂ����݂����ꍇ + if (existsInFields > 0 || isTrackingThis) { + // this�I�u�W�F�N�g��ǐՒ��̏ꍇ + if (!Trace.isNull(thisObjectId)) { + objList.add(thisObjectId); // ����ɒT������ꍇ�A��U��菜���� thisObject �𕜊� + } else { + objList.add(null); // ������static�Ăяo���������ꍇ�A����ȏ�ǐՂ��Ȃ� + } + } +// if (existsInFields > 0) { +// // �t�B�[���h��R���Ɏ��ƒI�u�W�F�N�g�����݂����ꍇ +// if (isSrcSide) { +// srcObject = thisObj; +// } else { +// dstObject = thisObj; +// } +// } + if (tracePoint.isValid()) { + finalCount = 0; + return callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� + } + } + + for (int i = 0; i < objList.size(); i++) { + objList.remove(null); + } + if (objList.isEmpty()) { + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(true); + } else { + // �R���������ł��Ȃ����� + if (!methodExecution.isStatic()) { + finalCount++; + if (finalCount <= LOST_DECISION_EXTENSION) { + // final�ϐ����Q�Ƃ��Ă���ꍇ�R���������ł��Ȃ��”\��������̂ŁA�ǐՂ������I�������P�\���Ԃ�݂��� + if (tracePoint.isValid()) { + MethodExecution c = callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� + if (((DeltaAugmentationInfo)c.getAugmentation()).isCoodinator()) { + methodExecution = c; // �ǐՂ𑱂������ʃR�[�f�B�l�[�^�����‚����� + } + } + } else if (thisObj.getActualType().contains("$")) { + // �����������܂��͖����N���X�̏ꍇ�A���������I�u�W�F�N�g���O�����\�b�h�̓���final�ϐ�����擾�����Ƃ݂Ȃ��A����Ɏ����̒��̃t�B�[���h�̈��Ƃ݂Ȃ� + for (int i = objList.size() - 1; i >= 0; i--) { + String objectId = objList.get(i); + if (objectId != null) { + ObjectReference trackingObj = new ObjectReference(objectId); + boolean isSrcSide2 = true; + trackingObj = null; + if (objectId.equals(srcObject.getId())) { + isSrcSide2 = true; + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + isSrcSide2 = false; + trackingObj = dstObject; + } + if (trackingObj != null) { + r = new Reference(thisObjectId, trackingObj.getId(), + methodExecution.getThisClassName(), trackingObj.getActualType()); + r.setFinalLocal(true); + if (isSrcSide2) { + eStructure.addSrcSide(r); + srcObject = thisObj; + isSrcSide = true; + } else { + eStructure.addDstSide(r); + dstObject = thisObj; + isSrcSide = false; + } + existsInFields++; + objList.remove(objectId); + } + } + } + } + } + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(false); + } + finalCount = 0; + return methodExecution; + } + + /** + * �f���^���o�A���S���Y���̌Ăяo����T������(�ċA�Ăяo���ɂȂ��Ă���) + * @param trace ��͑Ώۃg���[�X + * @param methodExecution �T�����郁�\�b�h���s + * @param objList �ǐՒ��̃I�u�W�F�N�g + * @param isStatic�@�ÓI���\�b�h���ۂ� + * @param index�@objList���̂ǂ̃I�u�W�F�N�g��ǐՂ��Ă��̃��\�b�h���s�ɓ����Ă����̂� + * @throws TraceFileException + */ + protected void calleeSearch(Trace trace, TracePoint tracePoint, ArrayList objList, Boolean isStatic, int index, IAliasCollector aliasCollector) { + MethodExecution methodExecution = tracePoint.getMethodExecution(); + Boolean isResolved = false; + String objectId = objList.get(index); // calleeSearch() �ł͒ǐՑΏۂ̃I�u�W�F�N�g�͈�‚����A��objList��index�Ԗڂ̗v�f�ȊO�ύX���Ă͂����Ȃ� + String thisObjectId = methodExecution.getThisObjId(); + ArrayList fieldArrays = new ArrayList(); + ArrayList fieldArrayElements = new ArrayList(); + ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), + Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), + Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); + + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(false); // ��{�I��getter�Ăяo���̂͂������A���� + ArrayList argments = methodExecution.getArguments(); + ObjectReference trackingObj = null; + //static���o�R�����null�������Ă��鎞������ + if (objectId != null) { + String returnType = Trace.getReturnType(methodExecution.getSignature()); + if (objectId.equals(srcObject.getId())) { + trackingObj = srcObject; + trackingObj.setCalleeType(returnType); + } else if(objectId.equals(dstObject.getId())) { + trackingObj = dstObject; + trackingObj.setCalleeType(returnType); + } else { + trackingObj = new ObjectReference(objectId, null, returnType); + } + + Reference r; + // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch�Ăяo�� + do { + if (!tracePoint.isValid()) break; + Statement statement = tracePoint.getStatement(); + // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� + if (statement instanceof FieldAccess) { + FieldAccess fs = (FieldAccess)statement; + if (objectId != null && objectId.equals(fs.getValueObjId())) { + String ownerObjectId = fs.getContainerObjId(); + if (ownerObjectId.equals(thisObjectId)) { + // �t�B�[���h�Q�Ƃ̏ꍇ + if (objectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(thisObj, srcObject)); + srcObject = thisObj; + trackingObj = srcObject; + } else if(objectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(thisObj, dstObject)); + dstObject = thisObj; + trackingObj = dstObject; + } + if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = thisObjectId; + objList.set(index, objectId); + } else { + // ���ڎQ�Ƃ̏ꍇ + if (objectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(ownerObjectId, objectId, + fs.getContainerClassName(), srcObject.getActualType())); + srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + trackingObj = srcObject; + } else if(objectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(ownerObjectId, objectId, + fs.getContainerClassName(), dstObject.getActualType())); + dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + trackingObj = dstObject; + } + if (Trace.isNull(ownerObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = ownerObjectId; + objList.set(index, objectId); + } + isResolved = true; + } else { + // �I�u�W�F�N�g�̗R�������ڌ��‚���Ȃ������ꍇ�ł��A�����ꂩ�̔z��̗v�f�ɗR�����Ă���”\�������� + String refObjType = fs.getValueClassName(); + if (refObjType.startsWith("[L")) { + // �Q�Ƃ����t�B�[���h���z��̏ꍇ + if ((trackingObj.getActualType() != null && refObjType.endsWith(trackingObj.getActualType() + ";")) + || (trackingObj.getCalleeType() != null && refObjType.endsWith(trackingObj.getCalleeType() + ";")) + || (trackingObj.getCallerType() != null && refObjType.endsWith(trackingObj.getCallerType() + ";"))) { + // �z��̗v�f�̕����ǐՒ��̃I�u�W�F�N�g�̌^�ƈ�v�����ꍇ + String ownerObjectId = fs.getContainerObjId(); + if (ownerObjectId.equals(thisObjectId)) { + // �t�B�[���h�Q�Ƃ̏ꍇ�i���ɗR���̉”\�����Ȃ��Ƃ킩�������_�ŁA���̔z��̗v�f�ɗR�����Ă�����̂Ɛ�������B�j + fieldArrays.add(new ObjectReference(fs.getValueObjId(), refObjType)); + fieldArrayElements.add(trackingObj); + } else { + // ���ڎQ�Ƃ̏ꍇ(�{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u��������ׂ������A + // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� + // ��蒼��������B) + } + } + } + } + } else if (statement instanceof MethodInvocation) { + // �߂�l + MethodExecution childMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); + ObjectReference ret = childMethodExecution.getReturnValue(); + if (ret != null && objectId != null && objectId.equals(ret.getId())) { + childMethodExecution.setAugmentation(new DeltaAugmentationInfo()); + ((DeltaAugmentationInfo)childMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); + TracePoint childTracePoint = tracePoint.duplicate(); + childTracePoint.stepBackNoReturn(); + calleeSearch(trace, childTracePoint, objList, childMethodExecution.isStatic(), index, aliasCollector); // �Ăяo���������ɒT�� + if (childMethodExecution.isConstructor()) { + // �R���X�g���N�^�Ăяo���������ꍇ + if (objectId.equals(srcObject.getId())) { + r = new Reference(thisObj, srcObject); + r.setCreation(true); + eStructure.addSrcSide(r); + srcObject = thisObj; + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + r = new Reference(thisObj, dstObject); + r.setCreation(true); + eStructure.addDstSide(r); + dstObject = thisObj; + trackingObj = dstObject; + } + if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = thisObjectId; + objList.set(index, objectId); + isResolved = true; + isLost = false; + continue; + } + objectId = objList.get(index); + if (objectId == null) { + // static�Ăяo���̖߂�l�������ꍇ�i���Ԃ�j + trackingObj = null; + isResolved = true; + } else if (objectId.equals(srcObject.getId())) { + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + trackingObj = dstObject; + } + if (isLost) { + checkList.add(objList.get(index)); + isLost = false; + } + } else { + // �I�u�W�F�N�g�̗R�������ڌ��‚���Ȃ������ꍇ�ł��A�ǂ����̔z��̗v�f�ɗR�����Ă���”\�������� + String retType = ret.getActualType(); + if (retType.startsWith("[L")) { + // �߂�l���z��̏ꍇ + if ((trackingObj.getActualType() != null && retType.endsWith(trackingObj.getActualType() + ";")) + || (trackingObj.getCalleeType() != null && retType.endsWith(trackingObj.getCalleeType() + ";")) + || (trackingObj.getCallerType() != null && retType.endsWith(trackingObj.getCallerType() + ";"))) { + // �{���ɂ��̔z��̗v�f����擾���ꂽ���̂Ȃ炱���ŒǐՑΏۂ�u�������āA�Ăяo�����T�����ׂ������A + // ���̎��_�ő��̗R���̉”\����r���ł��Ȃ��B�����ŒǐՑΏۂ�u�������Ă��܂��ƁA��ŕʂɗR�������邱�Ƃ��킩�����ꍇ�� + // ��蒼��������B + } + } + } + } + } while (tracePoint.stepBackOver()); + + //�����T�� + if (argments.contains(new ObjectReference(objectId))) { + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(true); // �������K�v? + isResolved = true; + } + } + + //�R���N�V�����^�Ή� + Reference r; + if (methodExecution.isCollectionType()) { + if (objectId != null) { + // �R���N�V�����^�̏ꍇ�A�����ԁX�̗v�f�𒼐ڕێ����Ă���Ɖ��肷�� + if (objectId.equals(srcObject.getId())) { + r = new Reference(thisObj, srcObject); + r.setCollection(true); + eStructure.addSrcSide(r); + srcObject = thisObj; + } else if(objectId.equals(dstObject.getId())) { + r = new Reference(thisObj, dstObject); + r.setCollection(true); + eStructure.addDstSide(r); + dstObject =thisObj; + } + } + objList.set(index, methodExecution.getThisObjId()); + isResolved = true; // �K�v�Ȃ̂ł�? + } + + if (!isResolved && objectId != null) { + // �R�����ǂ��ɂ����‚���Ȃ����� + boolean isSrcSide = true; + if (objectId.equals(srcObject.getId())) { + isSrcSide = true; + } else if (objectId.equals(dstObject.getId())) { + isSrcSide = false; + } + if (trackingObj != null) { + // �܂��z������̗v�f��R���Ƃ��ċ^��(�������D��) + for (int i = 0; i < argments.size(); i++) { + ObjectReference argArray = argments.get(i); + if (argArray.getActualType().startsWith("[L") + && ((trackingObj.getActualType() != null && argArray.getActualType().endsWith(trackingObj.getActualType() + ";")) + || (trackingObj.getCalleeType() != null && argArray.getActualType().endsWith(trackingObj.getCalleeType() + ";")) + || (trackingObj.getCallerType() != null && argArray.getActualType().endsWith(trackingObj.getCallerType() + ";")))) { + // �^����v������z������̗v�f��R���Ƃ݂Ȃ� + isResolved = true; + objList.set(index, argArray.getId()); // �ǐՑΏۂ�z��v�f����z��ɒu������ + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(argArray.getId())); + r = new Reference(argArray.getId(), trackingObj.getId(), + argArray.getActualType(), trackingObj.getActualType()); + r.setArray(true); + if (isSrcSide) { + eStructure.addSrcSide(r); + srcObject = new ObjectReference(argArray.getId(), argArray.getActualType()); + } else { + eStructure.addDstSide(r); + dstObject = new ObjectReference(argArray.getId(), argArray.getActualType()); + } + objectId = null; + break; + } + } + if (objectId != null) { + // ���ɔz��t�B�[���h�̗v�f��R���Ƃ��ċ^��(�t�B�[���h�͈�������) + int indArg = fieldArrayElements.indexOf(trackingObj); + if (indArg != -1) { + // �^����v���Ă�̂Ŕz��t�B�[���h�̗v�f��R���Ƃ݂Ȃ� + isResolved = true; + ObjectReference fieldArray = fieldArrays.get(indArg); + objList.set(index, thisObjectId); // �ǐՑΏۂ�this�ɒu������ + r = new Reference(fieldArray.getId(), trackingObj.getId(), + fieldArray.getActualType(), trackingObj.getActualType()); + r.setArray(true); + if (isSrcSide) { + eStructure.addSrcSide(r); + eStructure.addSrcSide(new Reference(thisObjectId, fieldArray.getId(), + methodExecution.getThisClassName(), fieldArray.getActualType())); + srcObject = thisObj; + } else { + eStructure.addDstSide(r); + eStructure.addDstSide(new Reference(thisObjectId, fieldArray.getId(), + methodExecution.getThisClassName(), fieldArray.getActualType())); + dstObject = thisObj; + } + } + } + if (trackingObj.getActualType() != null && trackingObj.getActualType().startsWith("[L")) { + // �ǂ��ɂ����‚���Ȃ������ꍇ�A�T���Ă���̂��z��^�Ȃ�΁A���̃��\�b�h���Ő������ꂽ���̂ƍl���� + isResolved = true; + objList.set(index, thisObjectId); // �ǐՑΏۂ�this�ɒu������ + if (isSrcSide) { + eStructure.addSrcSide(new Reference(thisObjectId, trackingObj.getId(), + methodExecution.getThisClassName(), trackingObj.getActualType())); + srcObject = thisObj; + } else { + eStructure.addDstSide(new Reference(thisObjectId, trackingObj.getId(), + methodExecution.getThisClassName(), trackingObj.getActualType())); + dstObject = thisObj; + } + } + } + } + + if (objectId == null && isResolved && !isStatic) { // static �Ăяo������̖߂�l��Ԃ��Ă���ꍇ + objList.set(index, thisObjectId); // ������ǐՂ����� + if (Trace.isNull(srcObject.getId())) { + srcObject = thisObj; + } else if (Trace.isNull(dstObject.getId())) { + dstObject = thisObj; + } + } + + if (isStatic && !isResolved) { // ���͋N���肦�Ȃ�?(get�|�C���g�J�b�g���擾����悤�ɂ�������) + objList.set(index, null); + } + if(!isStatic && !isResolved){ + isLost = true; // final�ϐ�������N���X�ŎQ�Ƃ��Ă���”\�������邪�AcalleeSearch()�͕K���Ăяo�����ɕ��A���Ă����̂ŁA�����ł͉������Ȃ� + } + } + + /** + * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * @param targetRef �ΏۂƂȂ�Q�� + * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) + * @return ���o���� + */ + public ExtractedStructure extract(Reference targetRef, TracePoint before) { + return extract(targetRef, before, defaultAliasCollector); + } + + /** + * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * @param targetRef �ΏۂƂȂ�Q�� + * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) + * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i + * @return ���o���� + */ + public ExtractedStructure extract(Reference targetRef, TracePoint before, IAliasCollector aliasCollector) { + TracePoint creationTracePoint; + if (targetRef.isArray()) { + // srcId �̔z��� dstId ���������Ă���”\�������郁�\�b�h���s���擾�i�z���p�̏����j + creationTracePoint = trace.getArraySetTracePoint(targetRef, before); + } else if (targetRef.isCollection()) { + // srcId �̃R���N�V�����^�I�u�W�F�N�g�� dstId ���n����Ă��郁�\�b�h���s���擾�i�R���N�V�����^��p�̏����j + creationTracePoint = trace.getCollectionAddTracePoint(targetRef, before); + } else if (targetRef.isFinalLocal()) { + // srcId �̓����܂��͖����N���X�̃C���X�^���X�� final local �ϐ��ɑ������Ă��� dstId �� �I�u�W�F�N�g���n���ꂽ�”\�������郁�\�b�h���s���擾�ifinal local�̋^��������ꍇ�̏����j + creationTracePoint = trace.getCreationTracePoint(targetRef.getSrcObject(), before); + targetRef = new Reference(creationTracePoint.getMethodExecution().getThisObjId(), targetRef.getDstObjectId(), creationTracePoint.getMethodExecution().getThisClassName(), targetRef.getDstClassName()); + } else { + // �I�u�W�F�N�g�ԎQ�� r ���������ꂽ���\�b�h���s���擾�i�ʏ�j + creationTracePoint = trace.getFieldUpdateTracePoint(targetRef, before); + } + if (creationTracePoint == null) { + return null; + } + return extractSub(creationTracePoint, targetRef, aliasCollector); + } + + /** + * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * @param creationTracePoint �I�u�W�F�N�g�ԎQ�Ɛ����g���[�X�|�C���g(�t�B�[���h�ւ̑��) + * @return ���o���� + */ + public ExtractedStructure extract(TracePoint creationTracePoint) { + creationTracePoint = creationTracePoint.duplicate(); + Statement statement = creationTracePoint.getStatement(); + if (statement instanceof FieldUpdate) { + Reference targetRef = ((FieldUpdate)statement).getReference(); + return extractSub(creationTracePoint, targetRef, defaultAliasCollector); + } else { + return null; + } + } + + /** + * �݌v�ύX��̃A���S���Y���̋N�����\�b�h(������) + * @param creationTracePoint �I�u�W�F�N�g�ԎQ�Ɛ����g���[�X�|�C���g(�t�B�[���h�ւ̑��) + * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i + * @return ���o���� + */ + public ExtractedStructure extract(TracePoint creationTracePoint, IAliasCollector aliasCollector) { + creationTracePoint = creationTracePoint.duplicate(); + Statement statement = creationTracePoint.getStatement(); + if (statement instanceof FieldUpdate) { + Reference targetRef = ((FieldUpdate)statement).getReference(); + return extractSub(creationTracePoint, targetRef, aliasCollector); + } else { + return null; + } + } + + private ExtractedStructure extractSub(TracePoint creationTracePoint, Reference targetRef, IAliasCollector aliasCollector) { + eStructure = new ExtractedStructure(); + ArrayList objList = new ArrayList(); + srcObject = targetRef.getSrcObject(); + dstObject = targetRef.getDstObject(); +if (DEBUG1) { + System.out.println("extract delta of:" + targetRef.getSrcObject().getActualType() + "(" + targetRef.getSrcObjectId() + ")" + " -> " + targetRef.getDstObject().getActualType() + "(" + targetRef.getDstObjectId() + ")"); +} + if (!Trace.isNull(targetRef.getSrcObjectId())) { + objList.add(targetRef.getSrcObjectId()); + } else { + objList.add(null); + } + if (!Trace.isNull(targetRef.getDstObjectId())) { + objList.add(targetRef.getDstObjectId()); + } else { + objList.add(null); + } + return extractSub2(creationTracePoint, objList, aliasCollector); + } + + public ExtractedStructure extract(TracePoint tracePoint, ObjectReference argObj) { + return extract(tracePoint, argObj, defaultAliasCollector); + } + + public ExtractedStructure extract(TracePoint tracePoint, ObjectReference argObj, IAliasCollector aliasCollector) { + MethodExecution methodExecution = tracePoint.getMethodExecution(); + eStructure = new ExtractedStructure(); + ArrayList objList = new ArrayList(); + String thisObjectId = methodExecution.getThisObjId(); + objList.add(thisObjectId); + objList.add(argObj.getId()); + srcObject = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), + Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); + dstObject = argObj; +if (DEBUG1) { + System.out.println("extract delta of:" + methodExecution.getSignature() + " -> " + argObj.getActualType() + "(" + argObj.getId() + ")"); +} + return extractSub2(tracePoint, objList, aliasCollector); + } + + private ExtractedStructure extractSub2(TracePoint creationTracePoint, ArrayList objList, IAliasCollector aliasCollector) { + eStructure.setCreationMethodExecution(creationTracePoint.getMethodExecution()); + MethodExecution coordinator = callerSearch(trace, creationTracePoint, objList, null, aliasCollector); + eStructure.setCoordinator(coordinator); +if (DEBUG2) { + if (((DeltaAugmentationInfo)coordinator.getAugmentation()).isCoodinator()) { + System.out.println("Coordinator"); + } else { + System.out.println("Warning"); + } + System.out.println("coordinator:" + coordinator.getSignature()); + System.out.println("srcSide:"); + for (int i = 0; i < eStructure.getDelta().getSrcSide().size(); i++) { + Reference ref = eStructure.getDelta().getSrcSide().get(i); + if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { + System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); + } + } + System.out.println("dstSide:"); + for (int i = 0; i < eStructure.getDelta().getDstSide().size(); i++) { + Reference ref = eStructure.getDelta().getDstSide().get(i); + if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { + System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); + } + } + System.out.println("overCoordinator:"); + MethodExecution parent = coordinator.getParent(); + while (parent != null) { + System.out.println("\t" + parent.getSignature()); + parent = parent.getParent(); + } +} + return eStructure; + } + + /** + * ���ۂ̎Q�ƌ��ƎQ�Ɛ�̃I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) + * @param srcObj ��������ɂ���Q�ƌ��I�u�W�F�N�g + * @param dstObj ��������ɂ���Q�Ɛ�I�u�W�F�N�g + * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) + * @return�@���o���� + */ + public ExtractedStructure extract(Object srcObj, Object dstObj, TracePoint before) { + return extract(srcObj, dstObj, before, defaultAliasCollector); + } + + /** + * ���ۂ̎Q�ƌ��ƎQ�Ɛ�̃I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) + * @param srcObj ��������ɂ���Q�ƌ��I�u�W�F�N�g + * @param dstObj ��������ɂ���Q�Ɛ�I�u�W�F�N�g + * @param before �T���J�n�g���[�X�|�C���g(������ȑO��T��) + * @param aliasCollector �f���^���o���ɒǐՂ����I�u�W�F�N�g�̑S�G�C���A�X�����W���郊�X�i + * @return�@���o���� + */ + public ExtractedStructure extract(Object srcObj, Object dstObj, TracePoint before, IAliasCollector aliasCollector) { + Reference targetRef = new Reference(Integer.toString(System.identityHashCode(srcObj)), Integer.toString(System.identityHashCode(dstObj)), null, null); + return extract(targetRef, before, aliasCollector); + } + + /** + * ���\�b�h���s���̃g���[�X�|�C���g�Ǝ��ۂ̎Q�Ɛ�I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) + * @param tracePoint ���\�b�h���s���̃g���[�X�|�C���g + * @param arg ��������ɂ���Q�Ɛ�I�u�W�F�N�g(���[�J���ϐ�������ɂ��Q�Ɛ�) + * @return ���o���� + */ + public ExtractedStructure extract(TracePoint tracePoint, Object arg) { + return extract(tracePoint, arg, defaultAliasCollector); + } + + /** + * ���\�b�h���s���̃g���[�X�|�C���g�Ǝ��ۂ̎Q�Ɛ�I�u�W�F�N�g���w�肵�ăf���^�𒊏o����(�I�����C����͗p) + * @param tracePoint ���\�b�h���s���̃g���[�X�|�C���g + * @param arg ��������ɂ���Q�Ɛ�I�u�W�F�N�g(���[�J���ϐ�������ɂ��Q�Ɛ�) + * @return ���o���� + */ + public ExtractedStructure extract(TracePoint tracePoint, Object arg, IAliasCollector aliasCollector) { + ObjectReference argObj = new ObjectReference(Integer.toString(System.identityHashCode(arg))); + return extract(tracePoint, argObj, aliasCollector); + } + + /** + * �w�肵�����ۂ̃X���b�h��Ō��ݎ��s���̃��\�b�h���s���擾����(�I�����C����͗p) + * @param thread ���ݎ��s���̑ΏۃX���b�h + * @return thread ��Ō��ݎ��s���̃��\�b�h���s + */ + public MethodExecution getCurrentMethodExecution(Thread thread) { + return trace.getCurrentMethodExecution(thread); + } + + /** + * methodSignature �ɑO����v���郁�\�b�h�������ƒ��\�b�h�̍Ō�̎��s + * @param methodSignature ���\�b�h��(�O����v�Ō�������) + * @return �Y������Ō�̃��\�b�h���s + */ + public MethodExecution getLastMethodExecution(String methodSignature) { + return trace.getLastMethodExecution(methodSignature); + } + + /** + * methodSignature �ɑO����v���郁�\�b�h�������ƒ��\�b�h�� before �ȑO�̍Ō�̎��s + * @param methodSignature ���\�b�h��(�O����v�Ō�������) + * @param before�@�T���J�n�g���[�X�|�C���g(������ȑO��T��) + * @return�@�Y������Ō�̃��\�b�h���s + */ + public MethodExecution getLastMethodExecution(String methodSignature, TracePoint before) { + return trace.getLastMethodExecution(methodSignature, before); + } + + public ArrayList getMethodExecutions(String methodSignature) { + return trace.getMethodExecutions(methodSignature); + } + +// public ExtractedStructure extract(MethodExecution caller, MethodExecution callee) { +// eStructure = new ExtractedStructure(); +// ArrayList objList = new ArrayList(); +// String thisObjectId = caller.getThisObjId(); +// objList.add(thisObjectId); +// objList.add(callee.getThisObjId()); +// srcObject = new ObjectReference(thisObjectId, caller.getThisClassName(), +// Trace.getDeclaringType(caller.getSignature(), caller.isConstractor()), Trace.getDeclaringType(caller.getCallerSideSignature(), caller.isConstractor())); +// dstObject = new ObjectReference(callee.getThisObjId(), callee.getThisClassName(), +// Trace.getDeclaringType(callee.getSignature(), callee.isConstractor()), Trace.getDeclaringType(callee.getCallerSideSignature(), callee.isConstractor())); +//if (DEBUG1) { +// System.out.println("extract delta of:" + caller.getSignature() + " -> " + callee.getSignature()); +//} +// +// caller = new MethodExecution(caller); // ��͗p�p�����[�^���������������̂��g�p���� +// eStructure.setCreationMethodExecution(caller); +// MethodExecution coordinator = callerSearch(trace, caller, objList, null); +// eStructure.setCoordinator(coordinator); +//if (DEBUG2) { +// if (coordinator.isCoodinator()) { +// System.out.println("Coordinator"); +// } else { +// System.out.println("Warning"); +// } +// System.out.println("coordinator:" + coordinator.getSignature()); +// System.out.println("srcSide:"); +// for (int i = 0; i < eStructure.getDelta().getSrcSide().size(); i++) { +// Reference ref = eStructure.getDelta().getSrcSide().get(i); +// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { +// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); +// } +// } +// System.out.println("dstSide:"); +// for (int i = 0; i < eStructure.getDelta().getDstSide().size(); i++) { +// Reference ref = eStructure.getDelta().getDstSide().get(i); +// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { +// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); +// } +// } +// System.out.println("overCoordinator:"); +// MethodExecution parent = coordinator.getParent(); +// while (parent != null) { +// System.out.println("\t" + parent.getSignature()); +// parent = parent.getParent(); +// } +//} +// return eStructure; +// } +// +// +// /** +// * ���\�b�h�̈����Ƃ��ăI�u�W�F�N�g���Q�Ƃ����ꍇ�̃f���^�𒊏o���� +// * @param caller �Q�ƌ��̃��\�b�h +// * @param argObj �����Ƃ��ĎQ�Ƃ����I�u�W�F�N�g +// * @return�@���o���� +// */ +// public ExtractedStructure extract(MethodExecution caller, ObjectReference argObj) { +// eStructure = new ExtractedStructure(); +// ArrayList objList = new ArrayList(); +// String thisObjectId = caller.getThisObjId(); +// objList.add(thisObjectId); +// objList.add(argObj.getId()); +// srcObject = new ObjectReference(thisObjectId, caller.getThisClassName(), +// Trace.getDeclaringType(caller.getSignature(), caller.isConstractor()), Trace.getDeclaringType(caller.getCallerSideSignature(), caller.isConstractor())); +// dstObject = argObj; +//if (DEBUG1) { +// System.out.println("extract delta of:" + caller.getSignature() + " -> " + argObj.getActualType() + "(" + argObj.getId() + ")"); +//} +// +// caller = new MethodExecution(caller); // ��͗p�p�����[�^���������������̂��g�p���� +// eStructure.setCreationMethodExecution(caller); +// MethodExecution coordinator = callerSearch(trace, caller, objList, null); +// eStructure.setCoordinator(coordinator); +//if (DEBUG2) { +// if (coordinator.isCoodinator()) { +// System.out.println("Coordinator"); +// } else { +// System.out.println("Warning"); +// } +// System.out.println("coordinator:" + coordinator.getSignature()); +// System.out.println("srcSide:"); +// for (int i = 0; i < eStructure.getDelta().getSrcSide().size(); i++) { +// Reference ref = eStructure.getDelta().getSrcSide().get(i); +// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { +// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); +// } +// } +// System.out.println("dstSide:"); +// for (int i = 0; i < eStructure.getDelta().getDstSide().size(); i++) { +// Reference ref = eStructure.getDelta().getDstSide().get(i); +// if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { +// System.out.println("\t" + ref.getSrcClassName() + "(" + ref.getSrcObjectId() + ")" + " -> " + ref.getDstClassName() + "(" + ref.getDstObjectId() + ")"); +// } +// } +// System.out.println("overCoordinator:"); +// MethodExecution parent = coordinator.getParent(); +// while (parent != null) { +// System.out.println("\t" + parent.getSignature()); +// parent = parent.getParent(); +// } +//} +// return eStructure; +// } +} diff --git a/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java b/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java index 25c38e5..16be00d 100644 --- a/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java +++ b/src/org/ntlab/deltaExtractor/DeltaExtractorJSON.java @@ -1,622 +1,632 @@ -package org.ntlab.deltaExtractor; - -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map.Entry; - -import org.ntlab.trace.ArrayAccess; -import org.ntlab.trace.ArrayCreate; -import org.ntlab.trace.FieldAccess; -import org.ntlab.trace.FieldUpdate; -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.MethodInvocation; -import org.ntlab.trace.ObjectReference; -import org.ntlab.trace.Reference; -import org.ntlab.trace.Statement; -import org.ntlab.trace.Trace; -import org.ntlab.trace.TraceJSON; -import org.ntlab.trace.TracePoint; - -/** - * �f���^���o�A���S���Y��(�z��ւ̃A�N�Z�X�����m�ł���Javassist��JSON�g���[�X�ɑΉ����A�A���S���Y����P����) - * - * @author Nitta - * - */ -public class DeltaExtractorJSON extends DeltaExtractor { - public DeltaExtractorJSON(String traceFile) { - super(new TraceJSON(traceFile)); - } - - public DeltaExtractorJSON(TraceJSON trace) { - super(trace); - } - -// /** -// * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j -// * @param trace�@��͑Ώۃg���[�X -// * @param methodExecution �T�����郁�\�b�h���s -// * @param objList�@�ǐՒ��̃I�u�W�F�N�g -// * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s -// * @return ���‚������R�[�f�B�l�[�^ -// * @throws TraceFileException -// */ -// protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution) { -// return callerSearch(trace, tracePoint, objList, childMethodExecution, new IAliasCollector() { -// @Override -// public void addAlias(Alias alias) { -// } -// @Override -// public void changeTrackingObject(String from, String to) { -// } -// }); -// } - - /** - * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j - * @param trace�@��͑Ώۃg���[�X - * @param methodExecution �T�����郁�\�b�h���s - * @param objList�@�ǐՒ��̃I�u�W�F�N�g - * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s - * @return ���‚������R�[�f�B�l�[�^ - * @throws TraceFileException - */ - protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution, IAliasCollector aliasCollector) { - MethodExecution methodExecution = tracePoint.getMethodExecution(); - methodExecution.setAugmentation(new DeltaAugmentationInfo()); - eStructure.createParent(methodExecution); - String thisObjectId = methodExecution.getThisObjId(); - ArrayList removeList = new ArrayList(); // �ǐՂ��Ă���I�u�W�F�N�g���ō폜�ΏۂƂȂ��Ă������ - ArrayList creationList = new ArrayList(); // ���̃��\�b�h���s���ɐ������ꂽ�I�u�W�F�N�g - int existsInFields = 0; // ���̃��\�b�h���s���Ńt�B�[���h�ɗR�����Ă���I�u�W�F�N�g�̐�(1�ȏ�Ȃ炱�̃��\�b�h���s����this�Ɉˑ�) - boolean isTrackingThis = false; // �Ăяo�����this�Ɉˑ����� - boolean isSrcSide = true; // �Q�ƌ����Q�Ɛ�̂�����̑��̃I�u�W�F�N�g�̗R�������ǂ���this�I�u�W�F�N�g�ɓ��B������? - ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), - Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - - HashMap aliasList = new HashMap<>(); - - if (childMethodExecution == null) { - // �T���J�n���͈�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� - } - - if (childMethodExecution != null && objList.contains(childMethodExecution.getThisObjId())) { - // �Ăяo�����this�Ɉˑ����� - if (thisObjectId.equals(childMethodExecution.getThisObjId())) { - // �I�u�W�F�N�g���Ăяo���̂Ƃ��݈̂�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� - } - - aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, childMethodExecution.getThisObjId(), tracePoint.duplicate())); - } - - if (childMethodExecution != null) { - for (String objId : objList) { - if (!objId.equals(childMethodExecution.getThisObjId())) { - aliasCollector.addAlias(new Alias(Alias.AliasType.ACTUAL_ARGUMENT, -1, objId, tracePoint.duplicate())); // argIndex�͕s�� - } - } - } - - if (childMethodExecution != null && childMethodExecution.isConstructor()) { - // �Ăяo���悪�R���X�g���N�^�������ꍇ - int newIndex = objList.indexOf(childMethodExecution.getThisObjId()); - if (newIndex != -1) { - // �Ăяo���悪�ǐՑΏۂ̃R���X�g���N�^��������field�Ɠ��l�ɏ��� - removeList.add(childMethodExecution.getThisObjId()); - existsInFields++; - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - } - } - - if (childMethodExecution != null && Trace.getMethodName(childMethodExecution.getSignature()).startsWith("access$")) { - // �G���N���[�W���O�C���X�^���X�ɑ΂��郁�\�b�h�Ăяo���������ꍇ - String enclosingObj = childMethodExecution.getArguments().get(0).getId(); // �G���N���[�W���O�C���X�^���X�͑������ɓ����Ă���炵�� - int encIndex = objList.indexOf(enclosingObj); - if (encIndex != -1) { - // thisObject �ɒu����������Afield�Ɠ��l�ɏ��� - removeList.add(enclosingObj); - existsInFields++; - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - } - } - - // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch���ċA�Ăяo�� - while (tracePoint.stepBackOver()) { - Statement statement = tracePoint.getStatement(); - // ���ڎQ�ƁA�t�B�[���h�Q�Ƃ���єz��A�N�Z�X�̒T�� - if (statement instanceof FieldAccess) { - FieldAccess fs = (FieldAccess)statement; - String refObjectId = fs.getValueObjId(); - int index = objList.indexOf(refObjectId); - if (index != -1) { - String ownerObjectId = fs.getContainerObjId(); - - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ - removeList.add(refObjectId); - existsInFields++; // set�������get�����o���Ă���”\�������� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - aliasList.put(refObjectId, new Alias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate())); - } else { - // ���ڎQ�Ƃ̏ꍇ - if (refObjectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(ownerObjectId, refObjectId, - fs.getContainerClassName(), srcObject.getActualType())); - srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - } else if(refObjectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(ownerObjectId, refObjectId, - fs.getContainerClassName(), dstObject.getActualType())); - dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - } - objList.set(index, ownerObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate())); - aliasCollector.changeTrackingObject(refObjectId, ownerObjectId); //�ǐՑΏۃI�u�W�F�N�g�̐؂�ւ� - aliasCollector.addAlias(new Alias(Alias.AliasType.CONTAINER, 0, ownerObjectId, tracePoint.duplicate())); - } - } - } else if (statement instanceof ArrayAccess) { - ArrayAccess aa = (ArrayAccess)statement; - String elementObjectId = aa.getValueObjectId(); - int index = objList.indexOf(elementObjectId); - if (index != -1) { - // �z��A�N�Z�X�̏ꍇ - String arrayObjectId = aa.getArrayObjectId(); - if (elementObjectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(arrayObjectId, elementObjectId, - aa.getArrayClassName(), srcObject.getActualType())); - srcObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); - } else if(elementObjectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(arrayObjectId, elementObjectId, - aa.getArrayClassName(), dstObject.getActualType())); - dstObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); - } - objList.set(index, arrayObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_ELEMENT, aa.getIndex(), elementObjectId, tracePoint.duplicate())); - aliasCollector.changeTrackingObject(elementObjectId, arrayObjectId); //�ǐՑΏۃI�u�W�F�N�g�̐؂�ւ� - aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, arrayObjectId, tracePoint.duplicate())); - } - } else if (statement instanceof ArrayCreate) { - ArrayCreate ac = (ArrayCreate)statement; - String arrayObjectId = ac.getArrayObjectId(); - int index = objList.indexOf(arrayObjectId); - if (index != -1) { - // �z�񐶐��̏ꍇfield�Ɠ��l�ɏ��� - creationList.add(arrayObjectId); - removeList.add(arrayObjectId); - existsInFields++; - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - aliasList.put(arrayObjectId, new Alias(Alias.AliasType.ARRAY_CREATE, 0, arrayObjectId, tracePoint.duplicate())); - } - } else if (statement instanceof MethodInvocation) { - MethodExecution prevChildMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); - if (!prevChildMethodExecution.equals(childMethodExecution)) { - // �߂�l - ObjectReference ret = prevChildMethodExecution.getReturnValue(); - if (ret != null) { - int retIndex = -1; - retIndex = objList.indexOf(ret.getId()); - if (retIndex != -1) { - // �߂�l���R�������� - prevChildMethodExecution.setAugmentation(new DeltaAugmentationInfo()); - - if (prevChildMethodExecution.isConstructor()) { - // �ǐՑΏۂ�constractor���Ă�ł�����(�I�u�W�F�N�g�̐�����������)field�Ɠ��l�ɏ��� - String newObjId = ret.getId(); - creationList.add(newObjId); - removeList.add(newObjId); - existsInFields++; - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(newObjId)); // �ǐՑΏ� - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setSetterSide(false); // getter�Ăяo���Ɠ��l - aliasList.put(newObjId, new Alias(Alias.AliasType.CONSTRACTOR_INVOCATION, 0, newObjId, tracePoint.duplicate())); - continue; - } - String retObj = objList.get(retIndex); - aliasCollector.addAlias(new Alias(Alias.AliasType.METHOD_INVOCATION, 0, retObj, tracePoint.duplicate())); - if (removeList.contains(retObj)) { - // ��xget�Ō��o���ăt�B�[���h�Ɉˑ����Ă���Ɣ��f�������{���̗R�����߂�l���������Ƃ����������̂ŁA�t�B�[���h�ւ̈ˑ����L�����Z������ - removeList.remove(retObj); - existsInFields--; - if (existsInFields == 0) { - removeList.remove(thisObjectId); - } - } - ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(retObj)); // �ǐՑΏ� - TracePoint prevChildTracePoint = tracePoint.duplicate(); - prevChildTracePoint.stepBackNoReturn(); - calleeSearch(trace, prevChildTracePoint, objList, prevChildMethodExecution.isStatic(), retIndex, aliasCollector); // �Ăяo�����T�� - if (objList.get(retIndex) != null && objList.get(retIndex).equals(prevChildMethodExecution.getThisObjId())) { - if ( thisObjectId.equals(prevChildMethodExecution.getThisObjId())) { - // �Ăяo����Ńt�B�[���h�Ɉˑ����Ă����ꍇ�̏��� - removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� - isTrackingThis = true; // �Ăяo�����T���O�ɕ��� - } - aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, objList.get(retIndex), tracePoint.duplicate())); - } - if (isLost) { - checkList.add(objList.get(retIndex)); - isLost = false; - } - } - } - } - } - } - // --- ���̎��_�� tracePoint �͌Ăяo�������w���Ă��� --- - - // �R���N�V�����^�Ή� - if (methodExecution.isCollectionType()) { - objList.add(thisObjectId); - } - - // �����̎擾 - ArrayList arguments = methodExecution.getArguments(); - - // �����ƃt�B�[���h�ɓ���ID�̃I�u�W�F�N�g������ꍇ��z�� - Reference r; - for (int i = 0; i < removeList.size(); i++) { - String removeId = removeList.get(i); - if (arguments.contains(new ObjectReference(removeId))) { - removeList.remove(removeId); // �t�B�[���h�ƈ����̗����ɒǐՑΏۂ����݂����ꍇ�A������D��(���A�P�[�X) - } else if(objList.contains(removeId)) { - // �t�B�[���h�ɂ����Ȃ������ꍇ(�������A�I�u�W�F�N�g�̐������t�B�[���h�Ɠ��l�Ɉ���) - objList.remove(removeId); // �ǐՑΏۂ���O�� - if (!removeId.equals(thisObjectId)) { - // �t�B�[���h�ithis ���� removeId �ւ̎Q�Ɓj���f���^�̍\���v�f�ɂȂ� - if (removeId.equals(srcObject.getId())) { - r = new Reference(thisObj, srcObject); - r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? - eStructure.addSrcSide(r); - srcObject = thisObj; - isSrcSide = true; - } else if (removeId.equals(dstObject.getId())) { - r = new Reference(thisObj, dstObject); - r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? - eStructure.addDstSide(r); - dstObject = thisObj; - isSrcSide = false; - } - aliasCollector.addAlias(aliasList.get(removeId)); - aliasCollector.changeTrackingObject(removeId, thisObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, aliasList.get(removeId).getOccurrencePoint())); - } - } - } - // --- ���̎��_�� this ���ǐՑΏۂł������Ƃ��Ă� objList �̒����炢������폜����Ă��� --- - - // �����T�� - boolean existsInAnArgument = false; - for (int i = 0; i < objList.size(); i++) { - String objectId = objList.get(i); - if (objectId != null) { - ObjectReference trackingObj = new ObjectReference(objectId); - if (arguments.contains(trackingObj)) { - // �������R�������� - existsInAnArgument = true; - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); - aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(trackingObj), trackingObj.getId(), methodExecution.getEntryPoint())); - } else { - // �R�����ǂ��ɂ����‚���Ȃ����� - boolean isSrcSide2 = true; - trackingObj = null; - if (objectId.equals(srcObject.getId())) { - isSrcSide2 = true; - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - isSrcSide2 = false; - trackingObj = dstObject; - } - } - } - } - if (existsInAnArgument) { - // ������1�‚ł��ǐՑΏۂ����݂����ꍇ - if (existsInFields > 0 || isTrackingThis) { - // this�I�u�W�F�N�g��ǐՒ��̏ꍇ - if (!Trace.isNull(thisObjectId)) { - objList.add(thisObjectId); // ����ɒT������ꍇ�A��U��菜���� thisObject �𕜊� - } else { - objList.add(null); // ������static�Ăяo���������ꍇ�A����ȏ�ǐՂ��Ȃ� - } - } - if (tracePoint.isValid()) { - finalCount = 0; - return callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� - } - } - - for (int i = 0; i < objList.size(); i++) { - objList.remove(null); - } - if (objList.isEmpty()) { - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(true); - } else { - // �R���������ł��Ȃ����� - if (!methodExecution.isStatic()) { - finalCount++; - if (finalCount <= LOST_DECISION_EXTENSION) { - // final�ϐ����Q�Ƃ��Ă���ꍇ�R���������ł��Ȃ��”\��������̂ŁA�ǐՂ������I�������P�\���Ԃ�݂��� - if (tracePoint.isValid()) { - MethodExecution c = callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� - if (((DeltaAugmentationInfo)c.getAugmentation()).isCoodinator()) { - methodExecution = c; // �ǐՂ𑱂������ʃR�[�f�B�l�[�^�����‚����� - } - } - } else if (thisObj.getActualType().contains("$")) { - // �����������܂��͖����N���X�̏ꍇ�A���������I�u�W�F�N�g���O�����\�b�h�̓���final�ϐ�����擾�����Ƃ݂Ȃ��A����Ɏ����̒��̃t�B�[���h�̈��Ƃ݂Ȃ� - for (int i = objList.size() - 1; i >= 0; i--) { - String objectId = objList.get(i); - if (objectId != null) { - ObjectReference trackingObj = new ObjectReference(objectId); - boolean isSrcSide2 = true; - trackingObj = null; - if (objectId.equals(srcObject.getId())) { - isSrcSide2 = true; - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - isSrcSide2 = false; - trackingObj = dstObject; - } - if (trackingObj != null) { - r = new Reference(thisObjectId, trackingObj.getId(), - methodExecution.getThisClassName(), trackingObj.getActualType()); - r.setFinalLocal(true); - if (isSrcSide2) { - eStructure.addSrcSide(r); - srcObject = thisObj; - isSrcSide = true; - } else { - eStructure.addDstSide(r); - dstObject = thisObj; - isSrcSide = false; - } - existsInFields++; - objList.remove(objectId); - } - } - } - } - } - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(false); - } - finalCount = 0; - return methodExecution; - } - - /** - * �f���^���o�A���S���Y���̌Ăяo����T������(�ċA�Ăяo���ɂȂ��Ă���) - * @param trace ��͑Ώۃg���[�X - * @param methodExecution �T�����郁�\�b�h���s - * @param objList �ǐՒ��̃I�u�W�F�N�g - * @param isStatic�@�ÓI���\�b�h���ۂ� - * @param index�@objList���̂ǂ̃I�u�W�F�N�g��ǐՂ��Ă��̃��\�b�h���s�ɓ����Ă����̂� - * @throws TraceFileException - */ - protected void calleeSearch(Trace trace, TracePoint tracePoint, ArrayList objList, Boolean isStatic, int index, IAliasCollector aliasCollector) { - MethodExecution methodExecution = tracePoint.getMethodExecution(); - Boolean isResolved = false; - String objectId = objList.get(index); // calleeSearch() �ł͒ǐՑΏۂ̃I�u�W�F�N�g�͈�‚����A��objList��index�Ԗڂ̗v�f�ȊO�ύX���Ă͂����Ȃ� - String thisObjectId = methodExecution.getThisObjId(); - ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), - Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), - Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); - - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(false); // ��{�I��getter�Ăяo���̂͂������A���� - ArrayList arguments = methodExecution.getArguments(); - ObjectReference trackingObj = null; - - aliasCollector.addAlias(new Alias(Alias.AliasType.RETURN_VALUE, 0, objectId, tracePoint.duplicate())); - //static���o�R�����null�������Ă��鎞������ - if (objectId != null) { - String returnType = Trace.getReturnType(methodExecution.getSignature()); - if (objectId.equals(srcObject.getId())) { - trackingObj = srcObject; - trackingObj.setCalleeType(returnType); - } else if(objectId.equals(dstObject.getId())) { - trackingObj = dstObject; - trackingObj.setCalleeType(returnType); - } else { - trackingObj = new ObjectReference(objectId, null, returnType); - } - - Reference r; - // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch�Ăяo�� - do { - if (!tracePoint.isValid()) break; - Statement statement = tracePoint.getStatement(); - // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� - if (statement instanceof FieldAccess) { - FieldAccess fs = (FieldAccess)statement; - if (objectId != null && objectId.equals(fs.getValueObjId())) { - String ownerObjectId = fs.getContainerObjId(); - if (ownerObjectId.equals(thisObjectId)) { - // �t�B�[���h�Q�Ƃ̏ꍇ - if (objectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(thisObj, srcObject)); - srcObject = thisObj; - trackingObj = srcObject; - } else if(objectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(thisObj, dstObject)); - dstObject = thisObj; - trackingObj = dstObject; - } - aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, objectId, tracePoint.duplicate())); - aliasCollector.changeTrackingObject(objectId, ownerObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, ownerObjectId, tracePoint.duplicate())); - if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = thisObjectId; - objList.set(index, objectId); - } else { - // ���ڎQ�Ƃ̏ꍇ - if (objectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(ownerObjectId, objectId, - fs.getContainerClassName(), srcObject.getActualType())); - srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - trackingObj = srcObject; - } else if(objectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(ownerObjectId, objectId, - fs.getContainerClassName(), dstObject.getActualType())); - dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); - trackingObj = dstObject; - } - aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, objectId, tracePoint.duplicate())); - aliasCollector.changeTrackingObject(objectId, ownerObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.CONTAINER, 0, ownerObjectId, tracePoint.duplicate())); - if (Trace.isNull(ownerObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = ownerObjectId; - objList.set(index, objectId); - } - isResolved = true; - } - } else if (statement instanceof ArrayAccess) { - ArrayAccess aa = (ArrayAccess)statement; - if (objectId != null && objectId.equals(aa.getValueObjectId())) { - // �z��A�N�Z�X�̏ꍇ - String arrayObjectId = aa.getArrayObjectId(); - if (objectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(arrayObjectId, objectId, - aa.getArrayClassName(), srcObject.getActualType())); - srcObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); - trackingObj = srcObject; - } else if(objectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(arrayObjectId, objectId, - aa.getArrayClassName(), dstObject.getActualType())); - dstObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); - trackingObj = dstObject; - } - aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_ELEMENT, aa.getIndex(), objectId, tracePoint.duplicate())); - aliasCollector.changeTrackingObject(objectId, arrayObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, arrayObjectId, tracePoint.duplicate())); - objectId = arrayObjectId; - objList.set(index, objectId); - isResolved = true; - } - } else if (statement instanceof ArrayCreate) { - ArrayCreate ac = (ArrayCreate)statement; - if (objectId != null && objectId.equals(ac.getArrayObjectId())) { - // �z�񐶐��̏ꍇ - if (objectId.equals(srcObject.getId())) { - eStructure.addSrcSide(new Reference(thisObj, srcObject)); - srcObject = thisObj; - trackingObj = srcObject; - } else if(objectId.equals(dstObject.getId())) { - eStructure.addDstSide(new Reference(thisObj, dstObject)); - dstObject = thisObj; - trackingObj = dstObject; - } - aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_CREATE, 0, ac.getArrayObjectId(), tracePoint.duplicate())); - aliasCollector.changeTrackingObject(ac.getArrayObjectId(), thisObjectId); - aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); - if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = thisObjectId; - objList.set(index, objectId); - } - } else if (statement instanceof MethodInvocation) { - // �߂�l - MethodExecution childMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); - ObjectReference ret = childMethodExecution.getReturnValue(); - if (ret != null && objectId != null && objectId.equals(ret.getId())) { - childMethodExecution.setAugmentation(new DeltaAugmentationInfo()); - ((DeltaAugmentationInfo)childMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); - TracePoint childTracePoint = tracePoint.duplicate(); - childTracePoint.stepBackNoReturn(); - aliasCollector.addAlias(new Alias(Alias.AliasType.METHOD_INVOCATION, 0, ret.getId(), tracePoint.duplicate())); - calleeSearch(trace, childTracePoint, objList, childMethodExecution.isStatic(), index, aliasCollector); // �Ăяo���������ɒT�� - if (childMethodExecution.isConstructor()) { - // �R���X�g���N�^�Ăяo���������ꍇ - if (objectId.equals(srcObject.getId())) { - r = new Reference(thisObj, srcObject); - r.setCreation(true); - eStructure.addSrcSide(r); - srcObject = thisObj; - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - r = new Reference(thisObj, dstObject); - r.setCreation(true); - eStructure.addDstSide(r); - dstObject = thisObj; - trackingObj = dstObject; - } - if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ - else objectId = thisObjectId; - objList.set(index, objectId); - isResolved = true; - isLost = false; - continue; - } - objectId = objList.get(index); - if (objectId == null) { - // static�Ăяo���̖߂�l�������ꍇ�i���Ԃ�j - trackingObj = null; - isResolved = true; - } else if (objectId.equals(srcObject.getId())) { - trackingObj = srcObject; - } else if (objectId.equals(dstObject.getId())) { - trackingObj = dstObject; - } - if (isLost) { - checkList.add(objList.get(index)); - isLost = false; - } - if (objectId != null) { - if (childMethodExecution.getThisObjId().equals(objectId)) { - aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, objectId, tracePoint.duplicate())); - } - } - } - } - } while (tracePoint.stepBackOver()); - - //�����T�� - if (arguments.contains(new ObjectReference(objectId))) { - ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(true); // �������K�v? - isResolved = true; - aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(new ObjectReference(objectId)), objectId, methodExecution.getEntryPoint())); - } - } - - //�R���N�V�����^�Ή� - Reference r; - if (methodExecution.isCollectionType()) { - if (objectId != null) { - // �R���N�V�����^�̏ꍇ�A�����ԁX�̗v�f�𒼐ڕێ����Ă���Ɖ��肷�� - if (objectId.equals(srcObject.getId())) { - r = new Reference(thisObj, srcObject); - r.setCollection(true); - eStructure.addSrcSide(r); - srcObject = thisObj; - } else if(objectId.equals(dstObject.getId())) { - r = new Reference(thisObj, dstObject); - r.setCollection(true); - eStructure.addDstSide(r); - dstObject =thisObj; - } - } - objList.set(index, methodExecution.getThisObjId()); - isResolved = true; // �K�v�Ȃ̂ł�? - } - - if (objectId == null && isResolved && !isStatic) { // static �Ăяo������̖߂�l��Ԃ��Ă���ꍇ - objList.set(index, thisObjectId); // ������ǐՂ����� - if (Trace.isNull(srcObject.getId())) { - srcObject = thisObj; - } else if (Trace.isNull(dstObject.getId())) { - dstObject = thisObj; - } - } - - if (isStatic && !isResolved) { // ���͋N���肦�Ȃ�?(get�|�C���g�J�b�g���擾����悤�ɂ�������) - objList.set(index, null); - } - if(!isStatic && !isResolved){ - isLost = true; // final�ϐ�������N���X�ŎQ�Ƃ��Ă���”\�������邪�AcalleeSearch()�͕K���Ăяo�����ɕ��A���Ă����̂ŁA�����ł͉������Ȃ� - } - } -} +package org.ntlab.deltaExtractor; + +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map.Entry; + +import org.ntlab.trace.ArrayAccess; +import org.ntlab.trace.ArrayCreate; +import org.ntlab.trace.FieldAccess; +import org.ntlab.trace.FieldUpdate; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.MethodInvocation; +import org.ntlab.trace.ObjectReference; +import org.ntlab.trace.Reference; +import org.ntlab.trace.Statement; +import org.ntlab.trace.Trace; +import org.ntlab.trace.TraceJSON; +import org.ntlab.trace.TracePoint; + +/** + * �f���^���o�A���S���Y��(�z��ւ̃A�N�Z�X�����m�ł���Javassist��JSON�g���[�X�ɑΉ����A�A���S���Y����P����) + * + * @author Nitta + * + */ +public class DeltaExtractorJSON extends DeltaExtractor { + public DeltaExtractorJSON(String traceFile) { + super(new TraceJSON(traceFile)); + } + + public DeltaExtractorJSON(TraceJSON trace) { + super(trace); + } + + /** + * �f���^���o�A���S���Y���̌Ăяo�����T�������icalleeSearch�Ƒ��ݍċA�ɂȂ��Ă���j + * @param trace�@��͑Ώۃg���[�X + * @param methodExecution �T�����郁�\�b�h���s + * @param objList�@�ǐՒ��̃I�u�W�F�N�g + * @param child�@���O�ɒT�����Ă����Ăяo����̃��\�b�h���s + * @return ���‚������R�[�f�B�l�[�^ + * @throws TraceFileException + */ + protected MethodExecution callerSearch(Trace trace, TracePoint tracePoint, ArrayList objList, MethodExecution childMethodExecution, IAliasCollector aliasCollector) { + MethodExecution methodExecution = tracePoint.getMethodExecution(); + methodExecution.setAugmentation(new DeltaAugmentationInfo()); + eStructure.createParent(methodExecution); + String thisObjectId = methodExecution.getThisObjId(); + ArrayList removeList = new ArrayList(); // �ǐՂ��Ă���I�u�W�F�N�g���ō폜�ΏۂƂȂ��Ă������ + ArrayList creationList = new ArrayList(); // ���̃��\�b�h���s���ɐ������ꂽ�I�u�W�F�N�g + int existsInFields = 0; // ���̃��\�b�h���s���Ńt�B�[���h�ɗR�����Ă���I�u�W�F�N�g�̐�(1�ȏ�Ȃ炱�̃��\�b�h���s����this�Ɉˑ�) + boolean isTrackingThis = false; // �Ăяo�����this�Ɉˑ����� + boolean isSrcSide = true; // �Q�ƌ����Q�Ɛ�̂�����̑��̃I�u�W�F�N�g�̗R�������ǂ���this�I�u�W�F�N�g�ɓ��B������? + ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), + Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); + + HashMap aliasList = new HashMap<>(); + + if (childMethodExecution == null) { + // �T���J�n���͈�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + + if (childMethodExecution != null && objList.contains(childMethodExecution.getThisObjId())) { + // �Ăяo�����this�Ɉˑ����� + if (thisObjectId.equals(childMethodExecution.getThisObjId())) { + // �I�u�W�F�N�g���Ăяo���̂Ƃ��݈̂�U�폜���A�Ăяo�����̒T���𑱂���ۂɕ��������� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + + aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, childMethodExecution.getThisObjId(), tracePoint.duplicate())); + } + + if (childMethodExecution != null) { + for (String objId : objList) { + if (!objId.equals(childMethodExecution.getThisObjId())) { + aliasCollector.addAlias(new Alias(Alias.AliasType.ACTUAL_ARGUMENT, -1, objId, tracePoint.duplicate())); // argIndex�͕s�� + } + } + } + + if (childMethodExecution != null && childMethodExecution.isConstructor()) { + // �Ăяo���悪�R���X�g���N�^�������ꍇ + int newIndex = objList.indexOf(childMethodExecution.getThisObjId()); + if (newIndex != -1) { + // �Ăяo���悪�ǐՑΏۂ̃R���X�g���N�^��������field�Ɠ��l�ɏ��� + removeList.add(childMethodExecution.getThisObjId()); + existsInFields++; + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + } + } + + if (childMethodExecution != null && Trace.getMethodName(childMethodExecution.getSignature()).startsWith("access$")) { + // �G���N���[�W���O�C���X�^���X�ɑ΂��郁�\�b�h�Ăяo���������ꍇ + String enclosingObj = childMethodExecution.getArguments().get(0).getId(); // �G���N���[�W���O�C���X�^���X�͑������ɓ����Ă���炵�� + int encIndex = objList.indexOf(enclosingObj); + if (encIndex != -1) { + // thisObject �ɒu����������Afield�Ɠ��l�ɏ��� + removeList.add(enclosingObj); + existsInFields++; + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + } + } + + // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch���ċA�Ăяo�� + while (tracePoint.stepBackOver()) { + Statement statement = tracePoint.getStatement(); + // ���ڎQ�ƁA�t�B�[���h�Q�Ƃ���єz��A�N�Z�X�̒T�� + if (statement instanceof FieldAccess) { + FieldAccess fs = (FieldAccess)statement; + String refObjectId = fs.getValueObjId(); + int index = objList.indexOf(refObjectId); + if (index != -1) { + String ownerObjectId = fs.getContainerObjId(); + + if (ownerObjectId.equals(thisObjectId)) { + // �t�B�[���h�Q�Ƃ̏ꍇ + removeList.add(refObjectId); + existsInFields++; // set�������get�����o���Ă���”\�������� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + aliasList.put(refObjectId, new Alias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate())); + } else { + // ���ڎQ�Ƃ̏ꍇ + boolean isSrcSideChanged = false; + if (refObjectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(ownerObjectId, refObjectId, + fs.getContainerClassName(), srcObject.getActualType())); + srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + isSrcSideChanged = true; + } else if(refObjectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(ownerObjectId, refObjectId, + fs.getContainerClassName(), dstObject.getActualType())); + dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + isSrcSideChanged = false; + } + objList.set(index, ownerObjectId); + aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, refObjectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(refObjectId, ownerObjectId, isSrcSideChanged); //�ǐՑΏۃI�u�W�F�N�g�̐؂�ւ� + aliasCollector.addAlias(new Alias(Alias.AliasType.CONTAINER, 0, ownerObjectId, tracePoint.duplicate())); + } + } + } else if (statement instanceof ArrayAccess) { + ArrayAccess aa = (ArrayAccess)statement; + String elementObjectId = aa.getValueObjectId(); + int index = objList.indexOf(elementObjectId); + if (index != -1) { + // �z��A�N�Z�X�̏ꍇ + boolean isSrcSideChanged = false; + String arrayObjectId = aa.getArrayObjectId(); + if (elementObjectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(arrayObjectId, elementObjectId, + aa.getArrayClassName(), srcObject.getActualType())); + srcObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); + isSrcSideChanged = true; + } else if(elementObjectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(arrayObjectId, elementObjectId, + aa.getArrayClassName(), dstObject.getActualType())); + dstObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); + isSrcSideChanged = false; + } + objList.set(index, arrayObjectId); + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_ELEMENT, aa.getIndex(), elementObjectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(elementObjectId, arrayObjectId, isSrcSideChanged); //�ǐՑΏۃI�u�W�F�N�g�̐؂�ւ� + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, arrayObjectId, tracePoint.duplicate())); + } + } else if (statement instanceof ArrayCreate) { + ArrayCreate ac = (ArrayCreate)statement; + String arrayObjectId = ac.getArrayObjectId(); + int index = objList.indexOf(arrayObjectId); + if (index != -1) { + // �z�񐶐��̏ꍇfield�Ɠ��l�ɏ��� + creationList.add(arrayObjectId); + removeList.add(arrayObjectId); + existsInFields++; + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + aliasList.put(arrayObjectId, new Alias(Alias.AliasType.ARRAY_CREATE, 0, arrayObjectId, tracePoint.duplicate())); + } + } else if (statement instanceof MethodInvocation) { + MethodExecution prevChildMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); + if (!prevChildMethodExecution.equals(childMethodExecution)) { + // �߂�l + ObjectReference ret = prevChildMethodExecution.getReturnValue(); + if (ret != null) { + int retIndex = -1; + retIndex = objList.indexOf(ret.getId()); + if (retIndex != -1) { + // �߂�l���R�������� + prevChildMethodExecution.setAugmentation(new DeltaAugmentationInfo()); + + if (prevChildMethodExecution.isConstructor()) { + // �ǐՑΏۂ�constractor���Ă�ł�����(�I�u�W�F�N�g�̐�����������)field�Ɠ��l�ɏ��� + String newObjId = ret.getId(); + creationList.add(newObjId); + removeList.add(newObjId); + existsInFields++; + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(newObjId)); // �ǐՑΏ� + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setSetterSide(false); // getter�Ăяo���Ɠ��l + aliasList.put(newObjId, new Alias(Alias.AliasType.CONSTRACTOR_INVOCATION, 0, newObjId, tracePoint.duplicate())); + continue; + } + String retObj = objList.get(retIndex); + aliasCollector.addAlias(new Alias(Alias.AliasType.METHOD_INVOCATION, 0, retObj, tracePoint.duplicate())); + if (removeList.contains(retObj)) { + // ��xget�Ō��o���ăt�B�[���h�Ɉˑ����Ă���Ɣ��f�������{���̗R�����߂�l���������Ƃ����������̂ŁA�t�B�[���h�ւ̈ˑ����L�����Z������ + removeList.remove(retObj); + existsInFields--; + if (existsInFields == 0) { + removeList.remove(thisObjectId); + } + } + ((DeltaAugmentationInfo)prevChildMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(retObj)); // �ǐՑΏ� + TracePoint prevChildTracePoint = tracePoint.duplicate(); + prevChildTracePoint.stepBackNoReturn(); + calleeSearch(trace, prevChildTracePoint, objList, prevChildMethodExecution.isStatic(), retIndex, aliasCollector); // �Ăяo�����T�� + if (objList.get(retIndex) != null && objList.get(retIndex).equals(prevChildMethodExecution.getThisObjId())) { + if ( thisObjectId.equals(prevChildMethodExecution.getThisObjId())) { + // �Ăяo����Ńt�B�[���h�Ɉˑ����Ă����ꍇ�̏��� + removeList.add(thisObjectId); // ��ň�U�AthisObject ����菜�� + isTrackingThis = true; // �Ăяo�����T���O�ɕ��� + } + aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, objList.get(retIndex), tracePoint.duplicate())); + } + if (isLost) { + checkList.add(objList.get(retIndex)); + isLost = false; + } + } + } + } + } + } + // --- ���̎��_�� tracePoint �͌Ăяo�������w���Ă��� --- + + // �R���N�V�����^�Ή� + if (methodExecution.isCollectionType()) { + objList.add(thisObjectId); + } + + // �����̎擾 + ArrayList arguments = methodExecution.getArguments(); + + // �����ƃt�B�[���h�ɓ���ID�̃I�u�W�F�N�g������ꍇ��z�� + Reference r; + for (int i = 0; i < removeList.size(); i++) { + String removeId = removeList.get(i); + if (arguments.contains(new ObjectReference(removeId))) { + removeList.remove(removeId); // �t�B�[���h�ƈ����̗����ɒǐՑΏۂ����݂����ꍇ�A������D��(���A�P�[�X) + } else if(objList.contains(removeId)) { + // �t�B�[���h�ɂ����Ȃ������ꍇ(�������A�I�u�W�F�N�g�̐������t�B�[���h�Ɠ��l�Ɉ���) + objList.remove(removeId); // �ǐՑΏۂ���O�� + if (!removeId.equals(thisObjectId)) { + // �t�B�[���h�ithis ���� removeId �ւ̎Q�Ɓj���f���^�̍\���v�f�ɂȂ� + if (removeId.equals(srcObject.getId())) { + r = new Reference(thisObj, srcObject); + r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? + eStructure.addSrcSide(r); + srcObject = thisObj; + isSrcSide = true; + } else if (removeId.equals(dstObject.getId())) { + r = new Reference(thisObj, dstObject); + r.setCreation(creationList.contains(removeId)); // �I�u�W�F�N�g�̐�����? + eStructure.addDstSide(r); + dstObject = thisObj; + isSrcSide = false; + } + aliasCollector.addAlias(aliasList.get(removeId)); + aliasCollector.changeTrackingObject(removeId, thisObjectId, isSrcSide); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, aliasList.get(removeId).getOccurrencePoint())); + } + } + } + // --- ���̎��_�� this ���ǐՑΏۂł������Ƃ��Ă� objList �̒����炢������폜����Ă��� --- + + // �����T�� + boolean existsInAnArgument = false; + for (int i = 0; i < objList.size(); i++) { + String objectId = objList.get(i); + if (objectId != null) { + ObjectReference trackingObj = new ObjectReference(objectId); + if (arguments.contains(trackingObj)) { + // �������R�������� + existsInAnArgument = true; + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); + aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(trackingObj), trackingObj.getId(), methodExecution.getEntryPoint())); + } else { + // �R�����ǂ��ɂ����‚���Ȃ����� + boolean isSrcSide2 = true; + trackingObj = null; + if (objectId.equals(srcObject.getId())) { + isSrcSide2 = true; + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + isSrcSide2 = false; + trackingObj = dstObject; + } + } + } + } + if (existsInAnArgument) { + // ������1�‚ł��ǐՑΏۂ����݂����ꍇ + if (existsInFields > 0 || isTrackingThis) { + // this�I�u�W�F�N�g��ǐՒ��̏ꍇ + if (!Trace.isNull(thisObjectId)) { + objList.add(thisObjectId); // ����ɒT������ꍇ�A��U��菜���� thisObject �𕜊� + } else { + objList.add(null); // ������static�Ăяo���������ꍇ�A����ȏ�ǐՂ��Ȃ� + } + } + if (tracePoint.isValid()) { + finalCount = 0; + return callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� + } + } + + for (int i = 0; i < objList.size(); i++) { + objList.remove(null); + } + if (objList.isEmpty()) { + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(true); + } else { + // �R���������ł��Ȃ����� + if (!methodExecution.isStatic()) { + finalCount++; + if (finalCount <= LOST_DECISION_EXTENSION) { + // final�ϐ����Q�Ƃ��Ă���ꍇ�R���������ł��Ȃ��”\��������̂ŁA�ǐՂ������I�������P�\���Ԃ�݂��� + if (tracePoint.isValid()) { + MethodExecution c = callerSearch(trace, tracePoint, objList, methodExecution, aliasCollector); // �Ăяo����������ɒT�� + if (((DeltaAugmentationInfo)c.getAugmentation()).isCoodinator()) { + methodExecution = c; // �ǐՂ𑱂������ʃR�[�f�B�l�[�^�����‚����� + } + } + } else if (thisObj.getActualType().contains("$")) { + // �����������܂��͖����N���X�̏ꍇ�A���������I�u�W�F�N�g���O�����\�b�h�̓���final�ϐ�����擾�����Ƃ݂Ȃ��A����Ɏ����̒��̃t�B�[���h�̈��Ƃ݂Ȃ� + for (int i = objList.size() - 1; i >= 0; i--) { + String objectId = objList.get(i); + if (objectId != null) { + ObjectReference trackingObj = new ObjectReference(objectId); + boolean isSrcSide2 = true; + trackingObj = null; + if (objectId.equals(srcObject.getId())) { + isSrcSide2 = true; + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + isSrcSide2 = false; + trackingObj = dstObject; + } + if (trackingObj != null) { + r = new Reference(thisObjectId, trackingObj.getId(), + methodExecution.getThisClassName(), trackingObj.getActualType()); + r.setFinalLocal(true); + if (isSrcSide2) { + eStructure.addSrcSide(r); + srcObject = thisObj; + isSrcSide = true; + } else { + eStructure.addDstSide(r); + dstObject = thisObj; + isSrcSide = false; + } + existsInFields++; + objList.remove(objectId); + } + } + } + } + } + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setCoodinator(false); + } + finalCount = 0; + return methodExecution; + } + + /** + * �f���^���o�A���S���Y���̌Ăяo����T������(�ċA�Ăяo���ɂȂ��Ă���) + * @param trace ��͑Ώۃg���[�X + * @param methodExecution �T�����郁�\�b�h���s + * @param objList �ǐՒ��̃I�u�W�F�N�g + * @param isStatic�@�ÓI���\�b�h���ۂ� + * @param index�@objList���̂ǂ̃I�u�W�F�N�g��ǐՂ��Ă��̃��\�b�h���s�ɓ����Ă����̂� + * @throws TraceFileException + */ + protected void calleeSearch(Trace trace, TracePoint tracePoint, ArrayList objList, Boolean isStatic, int index, IAliasCollector aliasCollector) { + MethodExecution methodExecution = tracePoint.getMethodExecution(); + Boolean isResolved = false; + String objectId = objList.get(index); // calleeSearch() �ł͒ǐՑΏۂ̃I�u�W�F�N�g�͈�‚����A��objList��index�Ԗڂ̗v�f�ȊO�ύX���Ă͂����Ȃ� + String thisObjectId = methodExecution.getThisObjId(); + ObjectReference thisObj = new ObjectReference(thisObjectId, methodExecution.getThisClassName(), + Trace.getDeclaringType(methodExecution.getSignature(), methodExecution.isConstructor()), + Trace.getDeclaringType(methodExecution.getCallerSideSignature(), methodExecution.isConstructor())); + + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(false); // ��{�I��getter�Ăяo���̂͂������A���� + ArrayList arguments = methodExecution.getArguments(); + ObjectReference trackingObj = null; + + aliasCollector.addAlias(new Alias(Alias.AliasType.RETURN_VALUE, 0, objectId, tracePoint.duplicate())); + //static���o�R�����null�������Ă��鎞������ + if (objectId != null) { + String returnType = Trace.getReturnType(methodExecution.getSignature()); + if (objectId.equals(srcObject.getId())) { + trackingObj = srcObject; + trackingObj.setCalleeType(returnType); + } else if(objectId.equals(dstObject.getId())) { + trackingObj = dstObject; + trackingObj.setCalleeType(returnType); + } else { + trackingObj = new ObjectReference(objectId, null, returnType); + } + + Reference r; + // �߂�l�ɒT���Ώۂ��܂܂�Ă����calleeSearch�Ăяo�� + do { + if (!tracePoint.isValid()) break; + Statement statement = tracePoint.getStatement(); + // ���ڎQ�Ƃ���уt�B�[���h�Q�Ƃ̒T�� + if (statement instanceof FieldAccess) { + FieldAccess fs = (FieldAccess)statement; + if (objectId != null && objectId.equals(fs.getValueObjId())) { + String ownerObjectId = fs.getContainerObjId(); + if (ownerObjectId.equals(thisObjectId)) { + // �t�B�[���h�Q�Ƃ̏ꍇ + boolean isSrcSideChanged = false; + if (objectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(thisObj, srcObject)); + srcObject = thisObj; + trackingObj = srcObject; + isSrcSideChanged = true; + } else if(objectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(thisObj, dstObject)); + dstObject = thisObj; + trackingObj = dstObject; + isSrcSideChanged = false; + } + aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, objectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(objectId, ownerObjectId, isSrcSideChanged); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, ownerObjectId, tracePoint.duplicate())); + if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = thisObjectId; + objList.set(index, objectId); + } else { + // ���ڎQ�Ƃ̏ꍇ + boolean isSrcSideChanged = false; + if (objectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(ownerObjectId, objectId, + fs.getContainerClassName(), srcObject.getActualType())); + srcObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + trackingObj = srcObject; + isSrcSideChanged = true; + } else if(objectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(ownerObjectId, objectId, + fs.getContainerClassName(), dstObject.getActualType())); + dstObject = new ObjectReference(ownerObjectId, fs.getContainerClassName()); + trackingObj = dstObject; + isSrcSideChanged = false; + } + aliasCollector.addAlias(new Alias(Alias.AliasType.FIELD, 0, objectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(objectId, ownerObjectId, isSrcSideChanged); + aliasCollector.addAlias(new Alias(Alias.AliasType.CONTAINER, 0, ownerObjectId, tracePoint.duplicate())); + if (Trace.isNull(ownerObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = ownerObjectId; + objList.set(index, objectId); + } + isResolved = true; + } + } else if (statement instanceof ArrayAccess) { + ArrayAccess aa = (ArrayAccess)statement; + if (objectId != null && objectId.equals(aa.getValueObjectId())) { + // �z��A�N�Z�X�̏ꍇ + boolean isSrcSideChanged = false; + String arrayObjectId = aa.getArrayObjectId(); + if (objectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(arrayObjectId, objectId, + aa.getArrayClassName(), srcObject.getActualType())); + srcObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); + trackingObj = srcObject; + isSrcSideChanged = true; + } else if(objectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(arrayObjectId, objectId, + aa.getArrayClassName(), dstObject.getActualType())); + dstObject = new ObjectReference(arrayObjectId, aa.getArrayClassName()); + trackingObj = dstObject; + isSrcSideChanged = false; + } + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_ELEMENT, aa.getIndex(), objectId, tracePoint.duplicate())); + aliasCollector.changeTrackingObject(objectId, arrayObjectId, isSrcSideChanged); + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY, 0, arrayObjectId, tracePoint.duplicate())); + objectId = arrayObjectId; + objList.set(index, objectId); + isResolved = true; + } + } else if (statement instanceof ArrayCreate) { + ArrayCreate ac = (ArrayCreate)statement; + if (objectId != null && objectId.equals(ac.getArrayObjectId())) { + // �z�񐶐��̏ꍇ + boolean isSrcSideChanged = false; + if (objectId.equals(srcObject.getId())) { + eStructure.addSrcSide(new Reference(thisObj, srcObject)); + srcObject = thisObj; + trackingObj = srcObject; + isSrcSideChanged = true; + } else if(objectId.equals(dstObject.getId())) { + eStructure.addDstSide(new Reference(thisObj, dstObject)); + dstObject = thisObj; + trackingObj = dstObject; + isSrcSideChanged = false; + } + aliasCollector.addAlias(new Alias(Alias.AliasType.ARRAY_CREATE, 0, ac.getArrayObjectId(), tracePoint.duplicate())); + aliasCollector.changeTrackingObject(ac.getArrayObjectId(), thisObjectId, isSrcSideChanged); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); + if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = thisObjectId; + objList.set(index, objectId); + } + } else if (statement instanceof MethodInvocation) { + // �߂�l + MethodExecution childMethodExecution = ((MethodInvocation)statement).getCalledMethodExecution(); + ObjectReference ret = childMethodExecution.getReturnValue(); + if (ret != null && objectId != null && objectId.equals(ret.getId())) { + childMethodExecution.setAugmentation(new DeltaAugmentationInfo()); + ((DeltaAugmentationInfo)childMethodExecution.getAugmentation()).setTraceObjectId(Integer.parseInt(objectId)); + TracePoint childTracePoint = tracePoint.duplicate(); + childTracePoint.stepBackNoReturn(); + if (!childMethodExecution.isConstructor()) { + aliasCollector.addAlias(new Alias(Alias.AliasType.METHOD_INVOCATION, 0, ret.getId(), tracePoint.duplicate())); + calleeSearch(trace, childTracePoint, objList, childMethodExecution.isStatic(), index, aliasCollector); // �Ăяo���������ɒT�� + } else { + aliasCollector.addAlias(new Alias(Alias.AliasType.CONSTRACTOR_INVOCATION, 0, ret.getId(), tracePoint.duplicate())); + } + if (childMethodExecution.isConstructor()) { + // �R���X�g���N�^�Ăяo���������ꍇ + if (objectId.equals(srcObject.getId())) { + r = new Reference(thisObj, srcObject); + r.setCreation(true); + eStructure.addSrcSide(r); + srcObject = thisObj; + trackingObj = srcObject; + aliasCollector.changeTrackingObject(objectId, thisObjectId, true); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); + } else if (objectId.equals(dstObject.getId())) { + r = new Reference(thisObj, dstObject); + r.setCreation(true); + eStructure.addDstSide(r); + dstObject = thisObj; + trackingObj = dstObject; + aliasCollector.changeTrackingObject(objectId, thisObjectId, false); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); + } + if (Trace.isNull(thisObjectId)) objectId = null; // static�ϐ��̏ꍇ + else objectId = thisObjectId; + objList.set(index, objectId); + isResolved = true; + isLost = false; + continue; + } + objectId = objList.get(index); + if (objectId == null) { + // static�Ăяo���̖߂�l�������ꍇ�i���Ԃ�j + trackingObj = null; + isResolved = true; + } else if (objectId.equals(srcObject.getId())) { + trackingObj = srcObject; + } else if (objectId.equals(dstObject.getId())) { + trackingObj = dstObject; + } + if (isLost) { + checkList.add(objList.get(index)); + isLost = false; + } + if (objectId != null) { + if (childMethodExecution.getThisObjId().equals(objectId)) { + aliasCollector.addAlias(new Alias(Alias.AliasType.RECEIVER, 0, objectId, tracePoint.duplicate())); + } + } + } + } + } while (tracePoint.stepBackOver()); + + //�����T�� + if (arguments.contains(new ObjectReference(objectId))) { + ((DeltaAugmentationInfo)methodExecution.getAugmentation()).setSetterSide(true); // �������K�v? + isResolved = true; + aliasCollector.addAlias(new Alias(Alias.AliasType.FORMAL_PARAMETER, arguments.indexOf(new ObjectReference(objectId)), objectId, methodExecution.getEntryPoint())); + } + } + + //�R���N�V�����^�Ή� + Reference r; + if (methodExecution.isCollectionType()) { + if (objectId != null) { + // �R���N�V�����^�̏ꍇ�A�����ԁX�̗v�f�𒼐ڕێ����Ă���Ɖ��肷�� + if (objectId.equals(srcObject.getId())) { + r = new Reference(thisObj, srcObject); + r.setCollection(true); + eStructure.addSrcSide(r); + srcObject = thisObj; + aliasCollector.changeTrackingObject(objectId, thisObjectId, true); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); + } else if(objectId.equals(dstObject.getId())) { + r = new Reference(thisObj, dstObject); + r.setCollection(true); + eStructure.addDstSide(r); + dstObject =thisObj; + aliasCollector.changeTrackingObject(objectId, thisObjectId, false); + aliasCollector.addAlias(new Alias(Alias.AliasType.THIS, 0, thisObjectId, tracePoint.duplicate())); + } + } + objList.set(index, methodExecution.getThisObjId()); + isResolved = true; // �K�v�Ȃ̂ł�? + } + + if (objectId == null && isResolved && !isStatic) { // static �Ăяo������̖߂�l��Ԃ��Ă���ꍇ + objList.set(index, thisObjectId); // ������ǐՂ����� + if (Trace.isNull(srcObject.getId())) { + srcObject = thisObj; + } else if (Trace.isNull(dstObject.getId())) { + dstObject = thisObj; + } + } + + if (isStatic && !isResolved) { // ���͋N���肦�Ȃ�?(get�|�C���g�J�b�g���擾����悤�ɂ�������) + objList.set(index, null); + } + if(!isStatic && !isResolved){ + isLost = true; // final�ϐ�������N���X�ŎQ�Ƃ��Ă���”\�������邪�AcalleeSearch()�͕K���Ăяo�����ɕ��A���Ă����̂ŁA�����ł͉������Ȃ� + } + } +} diff --git a/src/org/ntlab/deltaExtractor/ExtractedStructure.java b/src/org/ntlab/deltaExtractor/ExtractedStructure.java index dedf499..6e47f75 100644 --- a/src/org/ntlab/deltaExtractor/ExtractedStructure.java +++ b/src/org/ntlab/deltaExtractor/ExtractedStructure.java @@ -1,68 +1,68 @@ -package org.ntlab.deltaExtractor; - -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.Reference; - - -public class ExtractedStructure { - - private Delta delta = new Delta(); - private MethodExecution coordinator = null; - private MethodExecution parent = null; - private MethodExecution creationCallTree; - - public Delta getDelta() { - return delta; - } - - public MethodExecution getCoordinator() { - return coordinator; - } - - /** - * ������ ������ɍ폜���邱�� - * @param coordinator - */ - public void setCoordinator(MethodExecution coordinator) { - this.coordinator = coordinator; - } - - public void createParent(MethodExecution methodExecution) { - coordinator = methodExecution; - parent = null; - } - -// public void addParent(MethodExecution callTree) { -// if (parent == null) -// coordinator.addChild(parent = callTree); -// else -// parent.addChild(parent = callTree); -// } -// -// public void addChild(MethodExecution callTree) { -// if (parent == null) -// coordinator.addChild(callTree); -// else -// parent.addChild(callTree); -// } -// - public void addSrcSide(Reference reference) { - delta.addSrcSide(reference); - } - - public void addDstSide(Reference reference) { - delta.addDstSide(reference); - } - - public void changeParent() { - } - - public void setCreationMethodExecution(MethodExecution callTree) { - creationCallTree = callTree; - } - - public MethodExecution getCreationCallTree() { - return creationCallTree; - } - -} +package org.ntlab.deltaExtractor; + +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.Reference; + + +public class ExtractedStructure { + + private Delta delta = new Delta(); + private MethodExecution coordinator = null; + private MethodExecution parent = null; + private MethodExecution creationCallTree; + + public Delta getDelta() { + return delta; + } + + public MethodExecution getCoordinator() { + return coordinator; + } + + /** + * ������ ������ɍ폜���邱�� + * @param coordinator + */ + public void setCoordinator(MethodExecution coordinator) { + this.coordinator = coordinator; + } + + public void createParent(MethodExecution methodExecution) { + coordinator = methodExecution; + parent = null; + } + +// public void addParent(MethodExecution callTree) { +// if (parent == null) +// coordinator.addChild(parent = callTree); +// else +// parent.addChild(parent = callTree); +// } +// +// public void addChild(MethodExecution callTree) { +// if (parent == null) +// coordinator.addChild(callTree); +// else +// parent.addChild(callTree); +// } +// + public void addSrcSide(Reference reference) { + delta.addSrcSide(reference); + } + + public void addDstSide(Reference reference) { + delta.addDstSide(reference); + } + + public void changeParent() { + } + + public void setCreationMethodExecution(MethodExecution callTree) { + creationCallTree = callTree; + } + + public MethodExecution getCreationCallTree() { + return creationCallTree; + } + +} diff --git a/src/org/ntlab/deltaExtractor/IAliasCollector.java b/src/org/ntlab/deltaExtractor/IAliasCollector.java index 66b5388..0794023 100644 --- a/src/org/ntlab/deltaExtractor/IAliasCollector.java +++ b/src/org/ntlab/deltaExtractor/IAliasCollector.java @@ -1,21 +1,9 @@ -package org.ntlab.deltaExtractor; - -/** - * Collect delta aliases interface. - * - * @author Nitta Lab. - */ -public interface IAliasCollector { - - /** - * @param alias Object state in the flow of program execution. - */ - void addAlias(Alias alias); - - /** - * @param fromObjId - * @param toObjId - */ - void changeTrackingObject(String fromObjId, String toObjId); - -} +package org.ntlab.deltaExtractor; + +public interface IAliasCollector { + + void addAlias(Alias alias); + + void changeTrackingObject(String from, String to, boolean isSrcSide); + +} \ No newline at end of file diff --git a/src/org/ntlab/deltaExtractor/ObjectIdPair.java b/src/org/ntlab/deltaExtractor/ObjectIdPair.java new file mode 100644 index 0000000..b9bc5ae --- /dev/null +++ b/src/org/ntlab/deltaExtractor/ObjectIdPair.java @@ -0,0 +1,21 @@ +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/deltaExtractor/Test.java b/src/org/ntlab/deltaExtractor/Test.java index 5cadd9c..939c9ca 100644 --- a/src/org/ntlab/deltaExtractor/Test.java +++ b/src/org/ntlab/deltaExtractor/Test.java @@ -1,312 +1,324 @@ -package org.ntlab.deltaExtractor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; - -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.ObjectReference; -import org.ntlab.trace.Reference; -import org.ntlab.trace.ThreadInstance; -import org.ntlab.trace.Trace; -import org.ntlab.trace.TraceJSON; -import org.ntlab.trace.TracePoint; - -public class Test { - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - long time = System.nanoTime(); -// TraceJSON trace = new TraceJSON("traces\\_worstCase.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, "worstCase.P", "worstCase.M"), tp); - -// 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(); - ThreadInstance thread = threads.values().iterator().next(); - TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); - ExtractedStructure e = s.extract(new Reference(null, null, "arraySample.D", "arraySample.C"), tp); - -// 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()); - - } -} +package org.ntlab.deltaExtractor; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; + +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.ObjectReference; +import org.ntlab.trace.Reference; +import org.ntlab.trace.ThreadInstance; +import org.ntlab.trace.Trace; +import org.ntlab.trace.TraceJSON; +import org.ntlab.trace.TracePoint; + +public class Test { + + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + long time = System.nanoTime(); + TraceJSON trace = new TraceJSON("traces\\sampleCollection.trace"); + 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, "sampleCollection.D", "sampleCollection.C"), 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, boolean isSrcSide) { + 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()); + + } +} diff --git a/src/org/ntlab/deltaViewer/DeltaAliasCollector.java b/src/org/ntlab/deltaViewer/DeltaAliasCollector.java index ed0951e..9f4f44f 100644 --- a/src/org/ntlab/deltaViewer/DeltaAliasCollector.java +++ b/src/org/ntlab/deltaViewer/DeltaAliasCollector.java @@ -1,73 +1,101 @@ -package org.ntlab.deltaViewer; - -import java.util.ArrayList; -import java.util.Collection; - -import org.ntlab.deltaExtractor.Alias; -import org.ntlab.deltaExtractor.IAliasCollector; -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.MethodInvocation; - -/** - * Collect delta aliases for MagnetRON. - * - * @author Nitta Lab. - */ -public class DeltaAliasCollector implements IAliasCollector { - - private String srcObjId; - private String dstObjId; - private ArrayList aliasList = new ArrayList<>(); - - public DeltaAliasCollector() { - } - - /** - * @param srcObjId - * @param dstObjId - */ - public DeltaAliasCollector(String srcObjId, String dstObjId) { - this.srcObjId = srcObjId; - this.dstObjId = dstObjId; - } - - @Override - public void addAlias(Alias alias) { - switch(alias.getAliasType()) { - case RETURN_VALUE: - aliasList.add(0, alias); - break; - case METHOD_INVOCATION: - aliasList.add(0, alias); - break; - case FORMAL_PARAMETER: - aliasList.add(0, alias); - alias.getOccurrencePoint().getMethodExecution().getThisObjId(); - break; - case ACTUAL_ARGUMENT: - aliasList.add(0, alias); - break; - case THIS: - aliasList.add(0, alias); - break; - case RECEIVER: - aliasList.add(0, alias); - if (alias.getOccurrencePoint().getStatement() instanceof MethodInvocation) { - MethodExecution me = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); - } - break; - default: - } - System.out.println(alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo() + " : " + alias.getAliasType().toString()); - } - - @Override - public void changeTrackingObject(String fromObjId, String toObjId) { - System.out.println(fromObjId + " -> " + toObjId); - } - - public Collection getAliasList() { - return this.aliasList; - } - -} +package org.ntlab.deltaViewer; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.ntlab.deltaExtractor.Alias; +import org.ntlab.deltaExtractor.IAliasCollector; +import org.ntlab.deltaExtractor.ObjectIdPair; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.MethodInvocation; + +/** + * Collect delta aliases for MagnetRON. + * + * @author Nitta Lab. + */ +public class DeltaAliasCollector implements IAliasCollector { + // Reverse execution order. + private String srcObjId; + private String dstObjId; + private List aliasList = new ArrayList<>(); + private Map aliasToObjIdPairMap = new HashMap<>(); + + private Alias curAlias; + + public DeltaAliasCollector() { + } + + /** + * @param srcObjId + * @param dstObjId + */ + public DeltaAliasCollector(String srcObjId, String dstObjId) { + this.srcObjId = srcObjId; + this.dstObjId = dstObjId; + } + + @Override + public void addAlias(Alias alias) { + switch(alias.getAliasType()) { + case FORMAL_PARAMETER: + aliasList.add(0, alias); + break; + case THIS: + aliasList.add(0, alias); + break; + case METHOD_INVOCATION: + aliasList.add(0, alias); + break; + case CONSTRACTOR_INVOCATION: + aliasList.add(0, alias); + break; + case FIELD: + aliasList.add(0, alias); + break; + case ARRAY_ELEMENT: + aliasList.add(0, alias); + break; + case ARRAY: + aliasList.add(0, alias); + break; + case ACTUAL_ARGUMENT: + aliasList.add(0, alias); + break; + case RECEIVER: + aliasList.add(0, alias); + if (alias.getOccurrencePoint().getStatement() instanceof MethodInvocation) { + MethodExecution me = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); + } + break; + case RETURN_VALUE: + aliasList.add(0, alias); + break; + default: + break; + } + curAlias = alias; + System.out.println(alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo() + " : " + alias.getAliasType().toString()); + } + + @Override + public void changeTrackingObject(String fromObjId, String toObjId, boolean isSrcSideChanged) { + aliasToObjIdPairMap.put(curAlias, new ObjectIdPair(toObjId, fromObjId, isSrcSideChanged)); + System.out.println(fromObjId + " -> " + toObjId + " " + isSrcSideChanged); + } + + public List getAliasList() { + return this.aliasList; + } + + public Map getAliasToObjectPair() { + return aliasToObjIdPairMap; + } + + public ObjectIdPair getObjectPairByAlias(Alias alias) { + return aliasToObjIdPairMap.get(alias); + } +} diff --git a/src/org/ntlab/deltaViewer/DeltaAnimation.java b/src/org/ntlab/deltaViewer/DeltaAnimation.java index bc01761..c2494ce 100644 --- a/src/org/ntlab/deltaViewer/DeltaAnimation.java +++ b/src/org/ntlab/deltaViewer/DeltaAnimation.java @@ -1,355 +1,404 @@ -package org.ntlab.deltaViewer; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics2D; -import java.awt.Stroke; -import java.awt.geom.GeneralPath; -import java.awt.geom.Line2D; -import java.awt.geom.Path2D; -import java.util.Timer; -import java.util.TimerTask; - -import javax.swing.SwingUtilities; - -import com.mxgraph.canvas.mxGraphics2DCanvas; -import com.mxgraph.model.mxICell; -import com.mxgraph.swing.mxGraphComponent; -import com.mxgraph.util.mxPoint; - -/** - * Generate delta animation for MagnetRON. - * - * @author Nitta Lab. - */ -public class DeltaAnimation { - - private DeltaGraphAdapter mxgraph; - private mxGraphComponent mxgraphComponent; - - private Graphics2D graphics2D; - private Timer timer; - private static int FINAL_STEP_COUNT = 10; - - private mxICell sourceCell; - - GeneralPath p = new GeneralPath(); - - // X, Y - private mxPoint sourcePoint; - private mxPoint targetPoint; - private mxPoint curPoint; - private mxPoint updatePoint = new mxPoint(); - - // Width, Height - private Dimension targetDimension; - private Dimension curDimension = new Dimension(); - private Dimension updateDimension = new Dimension(); - - private double scale = 1; - - /** - * @param mxgraph - * @param mxgraphComponent - */ - public DeltaAnimation(DeltaGraphAdapter mxgraph, mxGraphComponent mxgraphComponent) { - this.mxgraph = mxgraph; - this.mxgraphComponent = mxgraphComponent; - graphics2D = (Graphics2D)mxgraphComponent.getGraphics(); - } - - /** - * @param zoomLevel Zoom level of MagnetRON view. - */ - public void setScale(double zoomLevel) { - this.scale = zoomLevel; - } - - /** - * Set to move animation sourcell vertex to targetPoint. - * - * @param sourceCell Vertex. - * @param targetPoint XY coordinates. - */ - public void setVertexAnimation(mxICell sourceCell, mxPoint targetPoint) { - this.sourceCell = sourceCell; - this.targetPoint = targetPoint; - curPoint = new mxPoint(sourceCell.getGeometry().getX(), sourceCell.getGeometry().getY()); -// System.out.println("sourcePoint : " + sourceCell.getGeometry().getPoint()); -// System.out.println("targetPoint : " + targetPoint); - calculateResizeLineModel(); - } - - /** - * Set stretch(expand) animation of edge from sourcePoint to targetPoint. - * - * @param sourcePoint Edge sourcePoint. - * @param targetPoint Edge targetPoint. - */ - public void setExpandEdgeAnimation(mxPoint sourcePoint, mxPoint targetPoint) { - this.sourcePoint = new mxPoint(sourcePoint.getX() * scale + 1, sourcePoint.getY() * scale + 1); - this.targetPoint = new mxPoint(targetPoint.getX() * scale, targetPoint.getY() * scale); - curPoint = this.sourcePoint; -// System.out.println("sourcePoint : " + sourcePoint); -// System.out.println("targetPoint : " + targetPoint); - - graphics2D = (Graphics2D)mxgraphComponent.getGraphics(); - graphics2D.setColor(Color.decode("#008000")); - - float width = (float) (1 * scale); - Stroke dashed = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{(float) (3.0f * scale * width), (float) (3.0f * scale * width)}, 0.0f); - graphics2D.setStroke(dashed); - calculateResizeLineModel(); - } - - /** - * Set to move animation sourcell vertex clone to targetPoint, reduce edge length. - * - * @param sourceCell Remove sourceCell vertex clone. - * @param targetPoint - */ - public void setReductionEdgeAnimation(mxICell sourceCell, mxPoint targetPoint) { - this.sourceCell = sourceCell; - this.targetPoint = targetPoint; - curPoint = new mxPoint(sourceCell.getGeometry().getX(), sourceCell.getGeometry().getY()); -// System.out.println("sourcePoint : " + sourceCell.getGeometry().getPoint()); -// System.out.println("targetPoint : " + targetPoint); - calculateResizeLineModel(); - } - - /** - * Set animation resize vertex. - * - * @param sourceCell - * @param targetDimension Vertex (Width, Height) - */ - public void setResizeVertexAnimation(mxICell sourceCell, Dimension targetDimension) { - this.sourceCell = sourceCell; - this.targetDimension = targetDimension; - curDimension.setSize(sourceCell.getGeometry().getWidth(), sourceCell.getGeometry().getHeight()); - calculateResizeVertexModel(); - } - - /** - * Calculate updatePoint every second from curPoint and targetPoint. - */ - public void calculateResizeLineModel() { - mxPoint distancePoint = new mxPoint(); - distancePoint.setX(targetPoint.getX() - curPoint.getX()); - distancePoint.setY(targetPoint.getY() - curPoint.getY()); - updatePoint.setX(distancePoint.getX() / FINAL_STEP_COUNT); - updatePoint.setY(distancePoint.getY() / FINAL_STEP_COUNT); - } - - /** - * Calculate updateDimension every second from curPoint and targetPoint. - */ - public void calculateResizeVertexModel() { - Dimension distanceDimension = new Dimension(); - distanceDimension.setSize(targetDimension.getWidth() - curDimension.getWidth(), targetDimension.getHeight() - curDimension.getWidth()); - updateDimension.setSize(distanceDimension.getWidth() / FINAL_STEP_COUNT, distanceDimension.getHeight() / FINAL_STEP_COUNT); - } - - /** - * Start animation to move sourcell vertex to targetPoint for 10 sec. - */ - public void startVertexAnimation() { - timer = new Timer(); - timer.schedule(new TimerTask() { - int stepCount = 0; - - @Override - public void run() { - if(stepCount < FINAL_STEP_COUNT) { - updateVertexAnimation(); - stepCount++; - if(stepCount >= FINAL_STEP_COUNT){ - timer.cancel(); - } - } - } - }, 0, 100); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * Start stretch(expand) animation of edge from sourcePoint to targetPoint for 10 sec. - */ - public void startExpandEdgeAnimation() { - timer = new Timer(); - timer.schedule(new TimerTask() { - int stepCount = 0; - - @Override - public void run() { - if(stepCount < FINAL_STEP_COUNT) { - updateExpandEdgeAnimation(); - stepCount++; - if(stepCount >= FINAL_STEP_COUNT){ - timer.cancel(); - } - } - } - }, 0, 100); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * Start move animation sourcell vertex clone to targetPoint, reduce edge length for 10 sec. - */ - public void startReductionEdgeAnimation() { - timer = new Timer(); - timer.schedule(new TimerTask() { - int stepCount = 0; - - @Override - public void run() { - if(stepCount < FINAL_STEP_COUNT) { - updateReductionEdgeAnimation(); - stepCount++; - if(stepCount >= FINAL_STEP_COUNT){ - timer.cancel(); - } - } - } - }, 0, 100); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * Start animation resize vertex for 10 sec. - */ - public void startResizeVertexAnimation() { - timer = new Timer(); - timer.schedule(new TimerTask() { - int stepCount = 0; - - @Override - public void run() { - if(stepCount < FINAL_STEP_COUNT) { - updateResizeVertexAnimation(); - stepCount++; - if(stepCount >= FINAL_STEP_COUNT){ - timer.cancel(); - } - } - } - }, 0, 100); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * Update animation to move sourcell vertex to targetPoint every second. - */ - private void updateVertexAnimation() { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - curPoint.setX(sourceCell.getGeometry().getX()); - curPoint.setY(sourceCell.getGeometry().getY()); - sourceCell.getGeometry().setX(curPoint.getX() + updatePoint.getX()); - sourceCell.getGeometry().setY(curPoint.getY() + updatePoint.getY()); -// System.out.println(sourceCell.getGeometry().getPoint()); - } finally { - mxgraph.getModel().endUpdate(); - } - mxgraphComponent.refresh(); - } - - /** - * Update stretch(expand) animation of edge length updatePoint every second. - */ - private void updateExpandEdgeAnimation() { - Runnable r = new Runnable() { - public void run() { - p.reset(); - p.moveTo((float)curPoint.getX(), (float)curPoint.getY()); - curPoint.setX(curPoint.getX() + updatePoint.getX()); - curPoint.setY(curPoint.getY() + updatePoint.getY()); -// System.out.println("curPoint : " + curPoint); - p.lineTo((float)curPoint.getX(), (float)curPoint.getY()); - graphics2D.draw(p); - } - }; - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - if (!SwingUtilities.isEventDispatchThread()) { - SwingUtilities.invokeLater(r); - } else { - r.run(); - } - } - - /** - * Update move animation sourcell vertex clone to targetPoint, reduce edge length updatePoint every second. - */ - private void updateReductionEdgeAnimation() { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - curPoint.setX(sourceCell.getGeometry().getX()); - curPoint.setY(sourceCell.getGeometry().getY()); - sourceCell.getGeometry().setX(curPoint.getX() + updatePoint.getX()); - sourceCell.getGeometry().setY(curPoint.getY() + updatePoint.getY()); - // System.out.println(sourceCell.getGeometry().getPoint()); - } finally { - mxgraph.getModel().endUpdate(); - } - mxgraphComponent.refresh(); - } - - /** - * Update animation resize vertex every second. - */ - private void updateResizeVertexAnimation() { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - double preCenterX = sourceCell.getGeometry().getCenterX(); - double preCenterY = sourceCell.getGeometry().getCenterY(); - - curDimension.setSize(sourceCell.getGeometry().getWidth(), sourceCell.getGeometry().getHeight()); - sourceCell.getGeometry().setWidth(curDimension.getWidth() + updateDimension.getWidth()); - sourceCell.getGeometry().setHeight(curDimension.getHeight() + updateDimension.getHeight()); - - double curCenterX = sourceCell.getGeometry().getCenterX(); - double curCenterY = sourceCell.getGeometry().getCenterY(); - double distanceX = (curCenterX - preCenterX); - double distanceY = (curCenterY - preCenterY); - double curX = sourceCell.getGeometry().getX(); - double curY = sourceCell.getGeometry().getY(); - - sourceCell.getGeometry().setX(curX - distanceX); - sourceCell.getGeometry().setY(curY - distanceY); - - for (int i = 0; i < sourceCell.getChildCount(); i++) { - mxICell childCell = sourceCell.getChildAt(i); - System.out.println("child" + childCell); - curX = childCell.getGeometry().getX(); - curY = childCell.getGeometry().getY(); - childCell.getGeometry().setX(curX + distanceX); - childCell.getGeometry().setY(curY + distanceY); - } - } finally { - mxgraph.getModel().endUpdate(); - } - mxgraphComponent.refresh(); - } -} +package org.ntlab.deltaViewer; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Stroke; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.Path2D; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +import javax.swing.SwingUtilities; + +import com.mxgraph.canvas.mxGraphics2DCanvas; +import com.mxgraph.model.mxICell; +import com.mxgraph.swing.mxGraphComponent; +import com.mxgraph.util.mxPoint; + +/** + * Generate delta animation for MagnetRON. + * + * @author Nitta Lab. + */ +public class DeltaAnimation { + + private DeltaGraphAdapter mxgraph; + private mxGraphComponent mxgraphComponent; + + private Graphics2D graphics2D; + private Timer timer; + private static int FINAL_STEP_COUNT = 10; + + private mxICell sourceCell; + + GeneralPath p = new GeneralPath(); + + // X, Y + private mxPoint sourcePoint; + private mxPoint targetPoint; + private mxPoint curPoint; + private mxPoint updatePoint = new mxPoint(); + + // Width, Height + private Dimension targetDimension; + private Dimension curDimension = new Dimension(); + private Dimension updateDimension = new Dimension(); + + private double scale = 1; + + /** + * @param mxgraph + * @param mxgraphComponent + */ + public DeltaAnimation(DeltaGraphAdapter mxgraph, mxGraphComponent mxgraphComponent) { + this.mxgraph = mxgraph; + this.mxgraphComponent = mxgraphComponent; + graphics2D = (Graphics2D)mxgraphComponent.getGraphics(); + } + + /** + * @param zoomLevel Zoom level of MagnetRON view. + */ + public void setScale(double zoomLevel) { + this.scale = zoomLevel; + } + + /** + * Set to move animation sourcell vertex to targetPoint. + * + * @param sourceCell Vertex. + * @param targetPoint XY coordinates. + */ + public void setVertexAnimation(mxICell sourceCell, mxPoint targetPoint) { + this.sourceCell = sourceCell; + this.targetPoint = targetPoint; + curPoint = new mxPoint(sourceCell.getGeometry().getX(), sourceCell.getGeometry().getY()); +// System.out.println("sourcePoint : " + sourceCell.getGeometry().getPoint()); +// System.out.println("targetPoint : " + targetPoint); + calculateResizeLineModel(); + } + + /** + * Set stretch(expand) animation of edge from sourcePoint to targetPoint. + * + * @param sourcePoint Edge sourcePoint. + * @param targetPoint Edge targetPoint. + */ + public void setExpandEdgeAnimation(mxPoint sourcePoint, mxPoint targetPoint) { + this.sourcePoint = new mxPoint(sourcePoint.getX() * scale + 1, sourcePoint.getY() * scale + 1); + this.targetPoint = new mxPoint(targetPoint.getX() * scale, targetPoint.getY() * scale); + curPoint = this.sourcePoint; +// System.out.println("sourcePoint : " + sourcePoint); +// System.out.println("targetPoint : " + targetPoint); + + graphics2D = (Graphics2D)mxgraphComponent.getGraphics(); + graphics2D.setColor(Color.decode("#008000")); + + float width = (float) (1 * scale); + Stroke dashed = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{(float) (3.0f * scale * width), (float) (3.0f * scale * width)}, 0.0f); + graphics2D.setStroke(dashed); + calculateResizeLineModel(); + } + + /** + * Set to move animation sourcell vertex clone to targetPoint, reduce edge length. + * + * @param sourceCell Remove sourceCell vertex clone. + * @param targetPoint + */ + public void setReductionEdgeAnimation(mxICell sourceCell, mxPoint targetPoint) { + this.sourceCell = sourceCell; + this.targetPoint = targetPoint; + curPoint = new mxPoint(sourceCell.getGeometry().getX(), sourceCell.getGeometry().getY()); +// System.out.println("sourcePoint : " + sourceCell.getGeometry().getPoint()); +// System.out.println("targetPoint : " + targetPoint); + calculateResizeLineModel(); + } + + /** + * Set animation resize vertex. + * + * @param sourceCell + * @param targetDimension Vertex (Width, Height) + */ + public void setResizeVertexAnimation(mxICell sourceCell, Dimension targetDimension) { + this.sourceCell = sourceCell; + this.targetDimension = targetDimension; + curDimension.setSize(sourceCell.getGeometry().getWidth(), sourceCell.getGeometry().getHeight()); + calculateResizeVertexModel(); + } + + /** + * Calculate updatePoint every second from curPoint and targetPoint. + */ + public void calculateResizeLineModel() { + mxPoint distancePoint = new mxPoint(); + distancePoint.setX(targetPoint.getX() - curPoint.getX()); + distancePoint.setY(targetPoint.getY() - curPoint.getY()); + updatePoint.setX(distancePoint.getX() / FINAL_STEP_COUNT); + updatePoint.setY(distancePoint.getY() / FINAL_STEP_COUNT); + } + + /** + * Calculate updateDimension every second from curPoint and targetPoint. + */ + public void calculateResizeVertexModel() { + Dimension distanceDimension = new Dimension(); + distanceDimension.setSize(targetDimension.getWidth() - curDimension.getWidth(), targetDimension.getHeight() - curDimension.getWidth()); + updateDimension.setSize(distanceDimension.getWidth() / FINAL_STEP_COUNT, distanceDimension.getHeight() / FINAL_STEP_COUNT); + } + + /** + * Start animation to move sourcell vertex to targetPoint for 10 sec. + */ + public void startVertexAnimation() { + timer = new Timer(); + timer.schedule(new TimerTask() { + int stepCount = 0; + + @Override + public void run() { + if(stepCount < FINAL_STEP_COUNT) { + updateVertexAnimation(); + stepCount++; + if(stepCount >= FINAL_STEP_COUNT){ + timer.cancel(); + } + } + } + }, 0, 100); + try { + Thread.sleep(1001); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * Start stretch(expand) animation of edge from sourcePoint to targetPoint for 10 sec. + */ + public void startExpandEdgeAnimation() { + timer = new Timer(); + timer.schedule(new TimerTask() { + int stepCount = 0; + + @Override + public void run() { + if(stepCount < FINAL_STEP_COUNT) { + updateExpandEdgeAnimation(); + stepCount++; + if(stepCount >= FINAL_STEP_COUNT){ + timer.cancel(); + } + } + } + }, 0, 100); + try { + Thread.sleep(1001); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * Start move animation sourcell vertex clone to targetPoint, reduce edge length for 10 sec. + */ + public void startReductionEdgeAnimation() { +// timer = new Timer(); +// timer.schedule(new TimerTask() { +// int stepCount = 0; +// +// @Override +// public void run() { +// if(stepCount < FINAL_STEP_COUNT) { +// updateReductionEdgeAnimation(); +// stepCount++; +// if(stepCount >= FINAL_STEP_COUNT){ +// timer.cancel(); +// } +// } +// } +// }, 0, 100); +// try { +// Thread.sleep(1001); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } + ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1); + scheduledThreadPoolExecutor.scheduleWithFixedDelay(new TimerTask() { + int stepCount = 0; + + @Override + public void run() { + if(stepCount < FINAL_STEP_COUNT) { + updateReductionEdgeAnimation(); + System.out.println(stepCount + ": " + curPoint.getX()); + stepCount++; + if(stepCount >= FINAL_STEP_COUNT){ + timer.cancel(); + } + } + } + }, 0, 100, TimeUnit.MILLISECONDS); + try { + System.out.println("Thread.sleep()"); + Thread.sleep(1001); + System.out.println("Thread.start()"); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * Start animation resize vertex for 10 sec. + */ + public void startResizeVertexAnimation() { +// timer = new Timer(); +// timer.schedule(new TimerTask() { +// int stepCount = 0; +// +// @Override +// public void run() { +// if(stepCount < FINAL_STEP_COUNT) { +// updateResizeVertexAnimation(); +// stepCount++; +// if(stepCount >= FINAL_STEP_COUNT){ +// timer.cancel(); +// } +// } +// } +// }, 0, 100); +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } + + ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1); + scheduledThreadPoolExecutor.scheduleWithFixedDelay(new TimerTask() { + int stepCount = 0; + + @Override + public void run() { + if(stepCount < FINAL_STEP_COUNT) { + updateResizeVertexAnimation(); + System.out.println(stepCount + ": " + curDimension.width); + stepCount++; + if(stepCount >= FINAL_STEP_COUNT){ + timer.cancel(); + } + } + } + }, 0, 100, TimeUnit.MILLISECONDS); + try { + System.out.println("Thread.sleep()"); + Thread.sleep(1001); + System.out.println("Thread.start()"); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + /** + * Update animation to move sourcell vertex to targetPoint every second. + */ + private void updateVertexAnimation() { + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + curPoint.setX(sourceCell.getGeometry().getX()); + curPoint.setY(sourceCell.getGeometry().getY()); + sourceCell.getGeometry().setX(curPoint.getX() + updatePoint.getX()); + sourceCell.getGeometry().setY(curPoint.getY() + updatePoint.getY()); +// System.out.println(sourceCell.getGeometry().getPoint()); + } finally { + mxgraph.getModel().endUpdate(); + } + mxgraphComponent.refresh(); + } + + /** + * Update stretch(expand) animation of edge length updatePoint every second. + */ + private void updateExpandEdgeAnimation() { + Runnable r = new Runnable() { + public void run() { + p.reset(); + p.moveTo((float)curPoint.getX(), (float)curPoint.getY()); + curPoint.setX(curPoint.getX() + updatePoint.getX()); + curPoint.setY(curPoint.getY() + updatePoint.getY()); +// System.out.println("curPoint : " + curPoint); + p.lineTo((float)curPoint.getX(), (float)curPoint.getY()); + graphics2D.draw(p); + } + }; + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(r); + } else { + r.run(); + } + } + + /** + * Update move animation sourcell vertex clone to targetPoint, reduce edge length updatePoint every second. + */ + private void updateReductionEdgeAnimation() { + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + curPoint.setX(sourceCell.getGeometry().getX()); + curPoint.setY(sourceCell.getGeometry().getY()); + sourceCell.getGeometry().setX(curPoint.getX() + updatePoint.getX()); + sourceCell.getGeometry().setY(curPoint.getY() + updatePoint.getY()); + // System.out.println(sourceCell.getGeometry().getPoint()); + } finally { + mxgraph.getModel().endUpdate(); + } + mxgraphComponent.refresh(); + } + + /** + * Update animation resize vertex every second. + */ + private void updateResizeVertexAnimation() { + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + double preCenterX = sourceCell.getGeometry().getCenterX(); + double preCenterY = sourceCell.getGeometry().getCenterY(); + + curDimension.setSize(sourceCell.getGeometry().getWidth(), sourceCell.getGeometry().getHeight()); + sourceCell.getGeometry().setWidth(curDimension.getWidth() + updateDimension.getWidth()); + sourceCell.getGeometry().setHeight(curDimension.getHeight() + updateDimension.getHeight()); + + double curCenterX = sourceCell.getGeometry().getCenterX(); + double curCenterY = sourceCell.getGeometry().getCenterY(); + double distanceX = (curCenterX - preCenterX); + double distanceY = (curCenterY - preCenterY); + double curX = sourceCell.getGeometry().getX(); + double curY = sourceCell.getGeometry().getY(); + + sourceCell.getGeometry().setX(curX - distanceX); + sourceCell.getGeometry().setY(curY - distanceY); + + for (int i = 0; i < sourceCell.getChildCount(); i++) { + mxICell childCell = sourceCell.getChildAt(i); +// System.out.println("child" + childCell); + curX = childCell.getGeometry().getX(); + curY = childCell.getGeometry().getY(); + childCell.getGeometry().setX(curX + distanceX); + childCell.getGeometry().setY(curY + distanceY); + } + } finally { + mxgraph.getModel().endUpdate(); + } + mxgraphComponent.refresh(); + } +} diff --git a/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java b/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java index b0398ff..f19a666 100644 --- a/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java +++ b/src/org/ntlab/deltaViewer/DeltaGraphAdapter.java @@ -1,152 +1,154 @@ -package org.ntlab.deltaViewer; - -import org.jgrapht.Graph; -import org.jgrapht.ext.JGraphXAdapter; -import org.jgrapht.graph.DefaultEdge; -import org.jgrapht.graph.DirectedWeightedPseudograph; - -import com.mxgraph.model.mxGeometry; -import com.mxgraph.model.mxICell; -import com.mxgraph.util.mxConstants; - -/** - * JGraphX(visualize) to JGraphT(model) DeltaGraphAdapter for MagnetRON. - * - * @author Nitta Lab. - */ -public class DeltaGraphAdapter extends JGraphXAdapter { - protected Graph graphT; - - public DeltaGraphAdapter(DirectedWeightedPseudograph graphT) { - super(graphT); - this.graphT = graphT; - } - - /** - * Draw new vertex into the graph. - * - * @param vertex Vertex to be added to the graph. - */ - private mxICell addJGraphTVertex(Object vertex) { - getModel().beginUpdate(); - - try { - // create a new JGraphX vertex at position 0 - mxICell cell = (mxICell) super.insertVertex(defaultParent, null, vertex, 0, 0, 0, 0); - - // update cell size so cell isn't "above" graph - updateCellSize(cell); - - // Save reference between vertex and cell. - getVertexToCellMap().put(vertex, cell); - getCellToVertexMap().put(cell, vertex); - return cell; - } finally { - getModel().endUpdate(); - } - } - - /** - * Draw new egde into the graph. - * - * @param edge Edge to be added to the graph. Source and target vertices are needed. - */ - private mxICell addJGraphTEdge(Object sourceVertex, Object targetVertex, 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; - } - - // get mxICells - Object sourceCell = getVertexToCellMap().get(sourceVertex); - Object targetCell = getVertexToCellMap().get(targetVertex); - - // add edge between mxICells - mxICell cell = (mxICell) super.insertEdge(defaultParent, null, edge, sourceCell, targetCell); - - // update cell size so cell isn't "above" graph - updateCellSize(cell); - - // Save reference between vertex and cell. - getEdgeToCellMap().put(edge, cell); - getCellToEdgeMap().put(cell, edge); - return cell; - } finally { - getModel().endUpdate(); - } - } - - /** - * - * @param parent - * @param id Edge id - * @param value Value to display - * @param source - * @param target - * @return - */ - public Object insertDeltaEdge(Object parent, String id, Object value, Object source, Object target) { - // find vertices of edge - Object sourceVertex = getCellToVertexMap().get(source); - Object targetVertex = getCellToVertexMap().get(target); - - if (value == null) { - graphT.addEdge(sourceVertex, targetVertex); - } else { - graphT.addEdge(sourceVertex, targetVertex, value); - } - mxICell cellEdge = addJGraphTEdge(sourceVertex, targetVertex, value); - cellEdge.setId(id); - return cellEdge; - } - - /** - * @param parent - * @param id Vertex id - * @param value Value to display - * @param style - * @return - */ - public Object insertDeltaVertex(Object parent, String id, Object value, String style) { - return insertDeltaVertex(parent, id, value, 0, 0, 0, 0, style); - } - - /** - * @param parent - * @param id Vertex id - * @param value Value to display - * @param x - * @param y - * @param width - * @param height - * @param style - * @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); - - cell.setId(id); - cell.setParent((mxICell) parent); - ((mxICell) parent).insert(cell); - getCellGeometry(cell).setX(x); - getCellGeometry(cell).setY(y); - getCellGeometry(cell).setWidth(width); - getCellGeometry(cell).setHeight(height); - String[] styles = style.split(";"); - for(String s: styles) { - if(s.contains("fillColor")) { - String[] splitS = s.split("="); - getCellStyle(cell).put(mxConstants.STYLE_FILLCOLOR, splitS[1]); - } - } - return cell; - } - - public Graph getGraph() { - return graphT; - } -} +package org.ntlab.deltaViewer; + +import org.jgrapht.Graph; +import org.jgrapht.ext.JGraphXAdapter; +import org.jgrapht.graph.DefaultEdge; +import org.jgrapht.graph.DirectedWeightedPseudograph; + +import com.mxgraph.model.mxCell; +import com.mxgraph.model.mxGeometry; +import com.mxgraph.model.mxICell; +import com.mxgraph.util.mxConstants; + +/** + * JGraphX(visualize) to JGraphT(model) DeltaGraphAdapter for MagnetRON. + * + * @author Nitta Lab. + */ +public class DeltaGraphAdapter extends JGraphXAdapter { + protected Graph graphT; + + public DeltaGraphAdapter(DirectedWeightedPseudograph graphT) { + super(graphT); + this.graphT = graphT; + } + + /** + * Draw new vertex into the graph. + * + * @param vertex Vertex to be added to the graph. + */ + private mxICell addJGraphTVertex(Object vertex) { + getModel().beginUpdate(); + + try { + // create a new JGraphX vertex at position 0 + mxICell cell = (mxICell) super.insertVertex(defaultParent, null, vertex, 0, 0, 0, 0); + + // update cell size so cell isn't "above" graph + updateCellSize(cell); + + // Save reference between vertex and cell. + getVertexToCellMap().put(vertex, cell); + getCellToVertexMap().put(cell, vertex); + return cell; + } finally { + getModel().endUpdate(); + } + } + + /** + * Draw new egde into the graph. + * + * @param edge Edge to be added to the graph. Source and target vertices are needed. + */ + private mxICell addJGraphTEdge(Object sourceVertex, Object targetVertex, 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; + } + + // get mxICells + Object sourceCell = getVertexToCellMap().get(sourceVertex); + Object targetCell = getVertexToCellMap().get(targetVertex); + + // add edge between mxICells + mxICell cell = (mxICell) super.insertEdge(defaultParent, null, edge, sourceCell, targetCell); + + // update cell size so cell isn't "above" graph + updateCellSize(cell); + + // Save reference between vertex and cell. + getEdgeToCellMap().put(edge, cell); + getCellToEdgeMap().put(cell, edge); + return cell; + } finally { + getModel().endUpdate(); + } + } + + /** + * + * @param parent + * @param id Edge id + * @param value Value to display + * @param source + * @param target + * @return + */ + public Object insertDeltaEdge(Object parent, String id, Object value, Object source, Object target) { + // find vertices of edge + Object sourceVertex = getCellToVertexMap().get(source); + Object targetVertex = getCellToVertexMap().get(target); + + if (value == null) { + graphT.addEdge(sourceVertex, targetVertex); + } else { + graphT.addEdge(sourceVertex, targetVertex, value); + } + mxICell cellEdge = addJGraphTEdge(sourceVertex, targetVertex, value); + cellEdge.setId(id); + return cellEdge; + } + + /** + * @param parent + * @param id Vertex id + * @param value Value to display + * @param style + * @return + */ + public Object insertDeltaVertex(Object parent, String id, Object value, String style) { + return insertDeltaVertex(parent, id, value, 0, 0, 0, 0, style); + } + + /** + * @param parent + * @param id Vertex id + * @param value Value to display + * @param x + * @param y + * @param width + * @param height + * @param style + * @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); + + cell.setId(id); + ((mxCell) parent).insert(cell); + cell.setParent((mxICell) parent); + + getCellGeometry(cell).setX(x); + getCellGeometry(cell).setY(y); + getCellGeometry(cell).setWidth(width); + getCellGeometry(cell).setHeight(height); + String[] styles = style.split(";"); + for(String s: styles) { + if(s.contains("fillColor")) { + String[] splitS = s.split("="); + getCellStyle(cell).put(mxConstants.STYLE_FILLCOLOR, splitS[1]); + } + } + return cell; + } + + public Graph getGraph() { + return graphT; + } +} diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 577f851..a9f1c3d 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -1,1008 +1,1240 @@ -package org.ntlab.deltaViewer; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.JFrame; - -import org.jgrapht.graph.DefaultEdge; -import org.jgrapht.graph.DirectedWeightedPseudograph; -import org.ntlab.deltaExtractor.Alias; -import org.ntlab.deltaExtractor.Delta; -import org.ntlab.deltaExtractor.ExtractedStructure; -import org.ntlab.deltaViewer.Edge.TypeName; -import org.ntlab.deltaExtractor.Alias.AliasType; -import org.ntlab.trace.FieldAccess; -import org.ntlab.trace.FieldUpdate; -import org.ntlab.trace.MethodExecution; -import org.ntlab.trace.MethodInvocation; -import org.ntlab.trace.Reference; -import org.ntlab.trace.Statement; - -import com.mxgraph.model.mxCell; -import com.mxgraph.model.mxICell; -import com.mxgraph.swing.mxGraphComponent; -import com.mxgraph.util.mxConstants; -import com.mxgraph.util.mxPoint; -import com.mxgraph.view.mxGraphView; - -/** - * Make and display JGraph of extracted delta. - * - * @author Nitta Lab. - */ -public class DeltaViewer { - private static Dimension DEFAULT_SIZE = new Dimension(700, 700); - private static String WINDOW_TITLE = "Delta Viewer"; - - private ExtractedStructure eStructure; - private DeltaAliasCollector deltaAliasCollector; - private List aliasList; - - private Map objectToVertexMap = new HashMap<>(); - private Map methodExecToVertexMap = new LinkedHashMap<>(); - private Map edgeMap = new HashMap<>(); - - private JFrame frame; - private DeltaGraphAdapter mxgraph; - // No clue what this does but it is needed. - private mxICell mxDefaultParent; - - private mxGraphComponent mxgraphComponent; - - private int curNumFrame = 0; - private static Dimension VERTEX_OBJECT_SIZE = new Dimension(70, 70); - private static Dimension VERTEX_METHOD_EXECUTION_SIZE = new Dimension(55, 20); - private mxPoint coordinatorPoint = new mxPoint(DEFAULT_SIZE.getWidth() / 2 - 50, 100); - - private DeltaAnimation deltaAnimation; - - private double scale = 1; - - public DeltaViewer() { - mxgraph = new DeltaGraphAdapter(new DirectedWeightedPseudograph(DefaultEdge.class)); - mxDefaultParent = (mxCell)mxgraph.getDefaultParent(); - mxgraphComponent = new mxGraphComponent(mxgraph); - deltaAnimation = new DeltaAnimation(mxgraph, mxgraphComponent); - } - - public DeltaViewer(ExtractedStructure extractedStructure, DeltaAliasCollector deltaAliasCollector) { - this(); - this.eStructure = extractedStructure; - this.deltaAliasCollector = deltaAliasCollector; - aliasList = new ArrayList<>(deltaAliasCollector.getAliasList()); -// init(); - } - - /** Initialize JFrame, make vertex object and edge object. */ - public void init() { - // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. - if(eStructure != null) { - WINDOW_TITLE = "extract delta of:" + eStructure.getDelta().getSrcSide().get(0).getDstClassName() + "(" + eStructure.getDelta().getSrcSide().get(0).getDstObjectId() + ")" + " -> " + eStructure.getDelta().getDstSide().get(0).getDstClassName() + "(" + eStructure.getDelta().getDstSide().get(0).getDstObjectId() + ")"; - } - - frame = new JFrame(WINDOW_TITLE); - frame.setSize(DEFAULT_SIZE); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - frame.add(mxgraphComponent, BorderLayout.CENTER); - frame.setVisible(true); - - while(coordinatorPoint.getX() - (150 * (eStructure.getDelta().getDstSide().size())) < 0) { - coordinatorPoint.setX(coordinatorPoint.getX() + 150); - } - - makeVertexObject(); - makeEdgeObject(); - - // Fit graph size in visiable JFrame. - mxGraphView view = mxgraphComponent.getGraph().getView(); - int componentWidth = mxgraphComponent.getWidth(); - int viewWidth = (int) view.getGraphBounds().getWidth(); - scale = (double)componentWidth/viewWidth; - view.setScale(scale); - deltaAnimation.setScale(scale); - System.out.println(componentWidth + ", " + viewWidth + ", " + scale); - } - - /** Display graph on JFrame. */ - public void display() { - setCellStyles(); - mxgraphComponent.refresh(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void setExtractedStructure(ExtractedStructure extractedStructure) { - this.eStructure = extractedStructure; - } - - public void setDeltaAliasCollector(DeltaAliasCollector deltaAliasCollector) { - this.deltaAliasCollector = deltaAliasCollector; - } - - public void setFrameSize(int width, int height) { - DEFAULT_SIZE.setSize(width, height); - } - - public void setCoordinatorPoint(double x, double y) { - coordinatorPoint.setX(x); - coordinatorPoint.setY(y); - } - - /** Set cell styles. */ - private void setCellStyles() { - List vertexObject = new ArrayList<>(); - List alignMiddleVertex = new ArrayList<>(); - List alignTopVertex = new ArrayList<>(); - List edgeObject = new ArrayList<>(); - List edgeMethodExec = new ArrayList<>(); - List roundEdge = new ArrayList<>(); - - for (VertexObject vertex: objectToVertexMap.values()) { - vertexObject.add(vertex.getCell()); - if(vertex.getMethodExecutions().size() == 0) { - alignMiddleVertex.add(vertex.getCell()); - } else { - alignTopVertex.add(vertex.getCell()); - } - } - - List vertexMethodExecList = new ArrayList<>(methodExecToVertexMap.values()); - Collections.reverse(vertexMethodExecList); - for (int i = 0; i < vertexMethodExecList.size(); i++) { - switch(i) { - case 0: - ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ff7fbf"); - break; - case 1: - ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ff99cc"); - break; - case 2: - ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffb2d8"); - break; - case 3: - ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffcce5"); - break; - case 4: - ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffe0ef"); - break; - default: - break; - } - } - - for (Edge edge: edgeMap.values()) { - roundEdge.add(edge.getCell()); - switch(edge.getTypeName()) { - case Reference: - edgeObject.add(edge.getCell()); - break; - case Call: - edgeMethodExec.add(edge.getCell()); - break; - default: - break; - } - } - /*Given a cell, we can change it's style attributes, for example the color. NOTE that you have to call the graphComponent.refresh() function, otherwise you won't see the difference! */ - mxgraph.setCellStyles(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE, vertexObject.toArray(new Object[vertexObject.size()])); - mxgraph.setCellStyles(mxConstants.STYLE_PERIMETER, mxConstants.PERIMETER_ELLIPSE, vertexObject.toArray(new Object[vertexObject.size()])); - mxgraph.setCellStyleFlags(mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_UNDERLINE, true, vertexObject.toArray(new Object[vertexObject.size()])); - mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE, alignMiddleVertex.toArray(new Object[alignMiddleVertex.size()])); - 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.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_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()])); -} - - 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 mxICell getRootParentCell(Object object) { - mxICell cell = (mxICell) object; - if(cell.getParent().getValue() == null) { - return cell; - } - return getRootParentCell(cell.getParent()); - } - - private Point getAbsolutePointforCell(Object object) { - mxICell cell = (mxICell) object; - Point p1 = cell.getGeometry().getPoint(); - if(cell.getParent().getValue() == null) { - return p1; - } - Point p2 = getAbsolutePointforCell(cell.getParent()); - return new Point((int) (p1.getX() + p2.getX()), (int) (p1.getY() + p2.getY())); - } - - /** - * Step to animation of specified alias. - * - * @param alias Alias type and occurance point etc. - */ - public void stepToAnimation(Alias alias) { - try { - stepToAnimation(aliasList.indexOf(alias)); - } catch (IndexOutOfBoundsException e) { - stepToAnimation(-1); - } - } - - /** - * Parent : Step to animation of specified numFrame. - * - * @param numFrame Current animation frame. - */ - public void stepToAnimation(int numFrame) { - try { - Alias alias = aliasList.get(numFrame); - makeAnimation(aliasList.get(curNumFrame + 1), alias); - curNumFrame = aliasList.indexOf(alias); - } catch (IndexOutOfBoundsException e) { - if (numFrame == - 1) { - System.out.println("ERROR : Not exist alias."); - } else { - System.out.println("\r\nLast Animation."); - makeLastAnimation(aliasList.get(aliasList.size() - 1)); - } - } - } - - /** - * Make animation from fromAlias to toAlias. - * - * @param fromAlias - * @param toAlias - */ - private void makeAnimation(Alias fromAlias, Alias toAlias) { - for (int i = aliasList.indexOf(fromAlias); i <= aliasList.indexOf(toAlias); i++) { - Alias alias = aliasList.get(i); - System.out.println("\r\n" + alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo() + " : " + alias.getAliasType().toString()); - switch(alias.getAliasType()) { - case RETURN_VALUE: - moveObjectVertex(alias); - break; - case METHOD_INVOCATION: - removeVertexMethodExecution(alias); - moveObjectVertex(alias); - break; - case FORMAL_PARAMETER: - moveObjectVertex(alias); - break; - case ACTUAL_ARGUMENT: - moveObjectVertex(alias); - break; - case THIS: - if (curNumFrame == 0) { - makeVertexMethodExecution(alias); - } - break; - case RECEIVER: - // Make VertexMethodExecution of called method execution. - MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); - if (!methodExecToVertexMap.containsKey(calledMethodExec)) { - makeVertexMethodExecution(alias, calledMethodExec.getSignature(), calledMethodExec); - } - break; - default: - break; - } - } - } - - /** - * Make last animation of extracted delta. - * - * @param alias Last index alias. - */ - private void makeLastAnimation(Alias alias) { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - // Make ObjectEdge and reset position of vertexObject, remove vertexMethodExecution. - for(Statement statement: alias.getMethodExecution().getStatements()) { - if(statement instanceof FieldUpdate) { - FieldUpdate fieldUpdateStatement = (FieldUpdate) statement; - String fieldNames[] = fieldUpdateStatement.getFieldName().split("\\."); - String fieldName = fieldNames[1]; - String sourceObjectId = fieldUpdateStatement.getContainerObjId(); - String targetObjectId = fieldUpdateStatement.getValueObjId(); - mxICell sourceCell = (mxICell)objectToVertexMap.get(sourceObjectId).getCell(); - mxICell targetCell = (mxICell)objectToVertexMap.get(targetObjectId).getCell(); - Point absolutePointTargetCell = getAbsolutePointforCell(targetCell); - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldUpdateStatement.getFieldName(), fieldName, objectToVertexMap.get(sourceObjectId).getCell(), objectToVertexMap.get(targetObjectId).getCell()); - - edgeMap.put(fieldUpdateStatement.getFieldName(), new Edge(fieldName, TypeName.Reference, edge)); - System.out.println("last" + objectToVertexMap.get(targetObjectId).getInitialX() + ", " + objectToVertexMap.get(targetObjectId).getInitialY()); - System.out.println(targetCell.getParent()); - targetCell.getParent().remove(targetCell); - targetCell.setParent(mxDefaultParent); - targetCell.getGeometry().setX(absolutePointTargetCell.getX()); - targetCell.getGeometry().setY(absolutePointTargetCell.getY()); - - deltaAnimation.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(targetObjectId).getInitialX(), objectToVertexMap.get(targetObjectId).getInitialY())); - deltaAnimation.startVertexAnimation(); - System.out.println(targetCell.getParent()); - targetCell.getGeometry().setX(objectToVertexMap.get(targetObjectId).getInitialX()); - targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); - removeCalledVertexMethodExecution(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); - updateVertexObjectSize(); - display(); - } - } - } finally { - mxgraph.getModel().endUpdate(); - } - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - - List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); - Collections.reverse(methodExecList); - for(int i = 0; i < methodExecList.size() - 1; i++) { - String objectId = methodExecList.get(i).getThisObjId(); - VertexObject sourceVertexObject = objectToVertexMap.get(objectId); // sourceVertex - MethodExecution methodExec = methodExecList.get(i); - for(Statement statement: methodExec.getStatements()) { - if(statement instanceof MethodInvocation) { - MethodExecution calledMethodExec = ((MethodInvocation) statement).getCalledMethodExecution(); - String calledObjectId = calledMethodExec.getThisObjId(); - mxICell calledCell = (mxICell)objectToVertexMap.get(calledObjectId).getCell(); - Point absolutePointCalledCell = getAbsolutePointforCell(calledCell); - System.out.println(objectId + ", " + methodExec.getSignature()); -// objectToVertexMap.get(calledObjectId).resetCellPosition(); - if (methodExecToVertexMap.get(methodExec).getArguments().contains(objectToVertexMap.get(calledObjectId)) || methodExecToVertexMap.get(methodExec).getLocals().contains(objectToVertexMap.get(calledObjectId))) { - calledCell.getParent().remove(calledCell); - calledCell.setParent(mxDefaultParent); - calledCell.getGeometry().setX(absolutePointCalledCell.getX()); - calledCell.getGeometry().setY(absolutePointCalledCell.getY()); - deltaAnimation.setVertexAnimation(calledCell, new mxPoint(objectToVertexMap.get(calledObjectId).getInitialX(), objectToVertexMap.get(calledObjectId).getInitialY())); - deltaAnimation.startVertexAnimation(); - } - removeCalledVertexMethodExecution(sourceVertexObject, methodExec.getCallerMethodExecution(), methodExec); - updateVertexObjectSize(); -// removeVertexMethodExecution(sourceVertexObject, methodExec); - display(); - break; - } - } - } - } finally { - mxgraph.getModel().endUpdate(); - } - - } - - /** Make VertexObject. */ - private void makeVertexObject() { - //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - // ����(0, 0) - double xCor = coordinatorPoint.getX(); - double yCor = coordinatorPoint.getY(); - double time = 150; - - mxgraph.getModel().beginUpdate(); - try { - // Draw vertex object. - // srcSide - Delta delta = eStructure.getDelta(); - int srcSideSize = delta.getSrcSide().size(); - for (int i = srcSideSize - 1; i >= 0; i--) { - Reference ref = delta.getSrcSide().get(i); - if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { - if(!objectToVertexMap.containsKey(ref.getSrcObjectId())) { - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getSrcClassName(), ref.getSrcClassName(), xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. -// mxgraph.updateCellSize(vertex, true); - objectToVertexMap.put(ref.getSrcObjectId(), new VertexObject(ref.getSrcClassName(), vertex, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)))); - } - if(!objectToVertexMap.containsKey(ref.getDstObjectId())) { - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstClassName(), ref.getDstClassName(), 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 VertexObject(ref.getDstClassName(), vertex, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)))); - } - } - } - - // dstSide - int dstSideSize = delta.getDstSide().size(); - for (int i = dstSideSize - 1; i >= 0; i--) { - Reference ref = delta.getDstSide().get(i); - if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { - Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstClassName(), ref.getDstClassName(), xCor - (time * (dstSideSize - i)), yCor + (time * (dstSideSize - i)), VERTEX_OBJECT_SIZE.getWidth(), VERTEX_OBJECT_SIZE.getHeight(), "fillColor=white"); //creates a white vertex. - objectToVertexMap.put(ref.getDstObjectId(), new VertexObject(ref.getDstClassName(), vertex, xCor - (time * (dstSideSize - i)), yCor + (time * (dstSideSize - i)))); - } - } - } finally { - mxgraph.getModel().endUpdate(); - } - } - - /** - * SourceVertex move targetVertex. - * - * @param alias - */ - private void moveObjectVertex(Alias alias) { - // sourceVertex - VertexObject sourceVertexObject = objectToVertexMap.get(alias.getObjectId()); - // targetVertex - VertexMethodExecution targetVertexMethodExec = methodExecToVertexMap.get(alias.getMethodExecution()); - - moveObjectVertex(alias, sourceVertexObject, targetVertexMethodExec); - updateVertexObjectSize(); - } - - /** - * Parent : Source VertexObject move target VertexMethodExecution. - * - * @param alias - * @param sourceVertexObject Source VertexObject. - * @param targetVertexMethodExec Target VertexMethodExecution. - */ - private void moveObjectVertex(Alias alias, VertexObject sourceVertexObject, VertexMethodExecution targetVertexMethodExec) { - MethodExecution methodExec = alias.getMethodExecution(); - if (alias.getAliasType().equals(AliasType.RETURN_VALUE) || alias.getAliasType().equals(AliasType.METHOD_INVOCATION)) { - moveLocalObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); - } else if (alias.getAliasType().equals(AliasType.FORMAL_PARAMETER)) { - moveArgumentObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); - } else if (alias.getAliasType().equals(AliasType.ACTUAL_ARGUMENT)) { - moveActualArgumentObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); - } - } - - /** - * Source VertexObject move target VertexMethodExecution to Local position from caller MethodExecution. - * - * @param callerMethodExec Caller MethodExecution. - * @param sourceVertexObject - * @param targetVertexMethodExec - */ - private void moveLocalObjectVertex(MethodExecution callerMethodExec, VertexObject sourceVertexObject, VertexMethodExecution targetVertexMethodExec) { - mxICell sourceCell = (mxICell)sourceVertexObject.getCell(); - mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); -// mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); - - // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. - MethodExecution callercallerMethodExec = callerMethodExec.getCallerMethodExecution(); - if (methodExecToVertexMap.containsKey(callercallerMethodExec) && methodExecToVertexMap.get(callercallerMethodExec).getLocals().contains(sourceVertexObject)) { - methodExecToVertexMap.get(callercallerMethodExec).getLocals().remove(sourceVertexObject); - System.out.println(methodExecToVertexMap.get(callercallerMethodExec).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); - } - - if (methodExecToVertexMap.containsKey(callercallerMethodExec) && methodExecToVertexMap.get(callercallerMethodExec).getArguments().contains(sourceVertexObject)) { - methodExecToVertexMap.get(callercallerMethodExec).getArguments().remove(sourceVertexObject); - System.out.println(methodExecToVertexMap.get(callercallerMethodExec).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); - } - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - int time = targetVertexMethodExec.getLocals().size() + 1; - double sourceX = sourceCell.getGeometry().getX(); - double sourceY = sourceCell.getGeometry().getY(); - - System.out.println(time); - - if(sourceCell.getParent().getValue() != null) { - Point absolutePointSourceCell = getAbsolutePointforCell(sourceCell); - sourceX = absolutePointSourceCell.getX(); - sourceY = absolutePointSourceCell.getY(); - sourceCell.getParent().remove(sourceCell); - } - - sourceCell.setParent(targetCell.getParent()); - targetCell.getParent().insert(sourceCell); - - Point absolutePointTargetCell = getAbsolutePointforCell(sourceCell.getParent()); - sourceCell.getGeometry().setX(sourceX - absolutePointTargetCell.getX()); - sourceCell.getGeometry().setY(sourceY - absolutePointTargetCell.getY()); - - double sourceWidth = sourceCell.getGeometry().getWidth(); - double sourceHeight = sourceCell.getGeometry().getHeight(); - double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); - double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); - - deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); - deltaAnimation.startVertexAnimation(); - - sourceCell.setParent(targetCell.getParent()); - targetCell.getParent().insert(sourceCell); - sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth); - sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); - targetVertexMethodExec.getLocals().add(sourceVertexObject); - System.out.println(targetVertexMethodExec.getLabel() + " :Local: " + sourceVertexObject.getLabel()); - } finally { - mxgraph.getModel().endUpdate(); - } - } - - /** - * Source VertexObject move target VertexMethodExecution to Argument position from MethodExecution. - * - * @param methodExec MethodExecution. - * @param sourceVertexObject - * @param targetVertexMethodExec - */ - private void moveArgumentObjectVertex(MethodExecution methodExec, VertexObject sourceVertexObject, VertexMethodExecution targetVertexMethodExec) { - mxICell sourceCell = (mxICell)sourceVertexObject.getCell(); - mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); -// mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); - - // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. - MethodExecution callerMethodExecution = methodExec.getCallerMethodExecution(); - if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getLocals().contains(sourceVertexObject)) { - methodExecToVertexMap.get(callerMethodExecution).getLocals().remove(sourceVertexObject); - System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); - } - - if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getArguments().contains(sourceVertexObject)) { - methodExecToVertexMap.get(callerMethodExecution).getArguments().remove(sourceVertexObject); - System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); - } - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - int time = targetVertexMethodExec.getArguments().size(); - double sourceX = sourceCell.getGeometry().getX(); - double sourceY = sourceCell.getGeometry().getY(); - - System.out.println(time); - - if(sourceCell.getParent().getValue() != null) { - Point absolutePointSourceCell = getAbsolutePointforCell(sourceCell); - sourceX = absolutePointSourceCell.getX(); - sourceY = absolutePointSourceCell.getY(); - sourceCell.getParent().remove(sourceCell); - } - - sourceCell.setParent(targetCell.getParent()); - targetCell.getParent().insert(sourceCell); - sourceCell.getGeometry().setX(sourceX - sourceCell.getParent().getGeometry().getX()); - sourceCell.getGeometry().setY(sourceY - sourceCell.getParent().getGeometry().getY()); - - double sourceWidth = sourceCell.getGeometry().getWidth(); - double sourceHeight = sourceCell.getGeometry().getHeight(); - double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); - double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); - - deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); - deltaAnimation.startVertexAnimation(); - -// sourceCell.setParent(targetCell.getParent()); -// targetCell.getParent().insert(sourceCell); - sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth); - sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); - targetVertexMethodExec.getArguments().add(sourceVertexObject); - System.out.println(targetVertexMethodExec.getLabel() + " :Argument: " + sourceVertexObject.getLabel()); - } finally { - mxgraph.getModel().endUpdate(); - } - } - - /** - * Source VertexObject move target VertexMethodExecution to Argument position from MethodExecution. - * - * @param methodExec MethodExecution. - * @param sourceVertexObject - * @param targetVertexMethodExec - */ - private void moveActualArgumentObjectVertex(MethodExecution methodExec, VertexObject sourceVertexObject, VertexMethodExecution targetVertexMethodExec) { - mxICell sourceCell = (mxICell)sourceVertexObject.getCell(); - mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); -// mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); - - // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. - MethodExecution callerMethodExecution = methodExec.getCallerMethodExecution(); - if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getLocals().contains(sourceVertexObject)) { - methodExecToVertexMap.get(callerMethodExecution).getLocals().remove(sourceVertexObject); - System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); - } - - if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getArguments().contains(sourceVertexObject)) { - methodExecToVertexMap.get(callerMethodExecution).getArguments().remove(sourceVertexObject); - System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); - } - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - int time = targetVertexMethodExec.getArguments().size(); - double sourceX = sourceCell.getGeometry().getX(); - double sourceY = sourceCell.getGeometry().getY(); - - System.out.println(time); - if (time == 0) time = 1; - - if(sourceCell.getParent().getValue() != null) { - Point absolutePointSourceCell = getAbsolutePointforCell(sourceCell); - sourceX = absolutePointSourceCell.getX(); - sourceY = absolutePointSourceCell.getY(); - sourceCell.getParent().remove(sourceCell); - } - - sourceCell.setParent(targetCell.getParent()); - targetCell.getParent().insert(sourceCell); - sourceCell.getGeometry().setX(sourceX - sourceCell.getParent().getGeometry().getX()); - sourceCell.getGeometry().setY(sourceY - sourceCell.getParent().getGeometry().getY()); - - double sourceWidth = sourceCell.getGeometry().getWidth(); - double sourceHeight = sourceCell.getGeometry().getHeight(); - double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); - double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); - - deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); - deltaAnimation.startVertexAnimation(); - sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth); - sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); - targetVertexMethodExec.getArguments().add(sourceVertexObject); - System.out.println(targetVertexMethodExec.getLabel() + " :Argument: " + sourceVertexObject.getLabel()); - } finally { - mxgraph.getModel().endUpdate(); - } - } - - /** Update VertexObject size. */ - private void updateVertexObjectSize() { - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology - mxgraph.getModel().beginUpdate(); - try { - for (VertexObject vertexObject: objectToVertexMap.values()) { - mxCell vertexObjectCell = ((mxCell) vertexObject.getCell()); - int time = vertexObjectCell.getChildCount(); - if (time == 0) { - time = 1; - } - - if(vertexObjectCell.getGeometry().getWidth() != VERTEX_OBJECT_SIZE.getWidth() * time) { - Dimension targetDimension = new Dimension(); - targetDimension.setSize(VERTEX_OBJECT_SIZE.getWidth() * time, VERTEX_OBJECT_SIZE.getHeight() * time); - deltaAnimation.setResizeVertexAnimation(vertexObjectCell, targetDimension); - deltaAnimation.startResizeVertexAnimation(); - } - } - }finally { - mxgraph.getModel().endUpdate(); - } - - show(mxDefaultParent); - } - - private void show(mxICell cell) { - for(Object object: mxgraph.getChildCells(cell)) { - System.out.println(object); - } - - } - /** - * Update VertexObject of targetMethodExecCell size have sourceObjectCell. - * - * @param sourceObjectCell - * @param targetMethodExecCell - */ - private void updateVertexObjectSize(mxICell sourceObjectCell, mxICell targetMethodExecCell) { - mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); - - //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - double preX = parentTargetMethodExecCell.getGeometry().getX(); - double preY = parentTargetMethodExecCell.getGeometry().getY(); - double preCenterX = parentTargetMethodExecCell.getGeometry().getCenterX(); - double preCenterY = parentTargetMethodExecCell.getGeometry().getCenterY(); - parentTargetMethodExecCell.getGeometry().setWidth(parentTargetMethodExecCell.getGeometry().getWidth() * 1.8); - parentTargetMethodExecCell.getGeometry().setHeight(parentTargetMethodExecCell.getGeometry().getHeight() * 1.8); - parentTargetMethodExecCell.getGeometry().setX(preX - (parentTargetMethodExecCell.getGeometry().getCenterX() - preCenterX)); - parentTargetMethodExecCell.getGeometry().setY(preY - (parentTargetMethodExecCell.getGeometry().getCenterY() - preCenterY)); - } finally { - mxgraph.getModel().endUpdate(); - } - } - - /** Make edge object in JGraphT and draw this in JGraphX. */ - private void makeEdgeObject() { - Map> fieldNameMap = new HashMap<>(); - - // Format field name. - for(Alias alias: aliasList) { - if(alias.getAliasType().equals(AliasType.THIS)) { - for(Statement statement: alias.getMethodExecution().getStatements()) { - if(statement instanceof FieldAccess) { - String fieldNames[] = formatFieldName(((FieldAccess)statement).getFieldName()); - if(fieldNameMap.get(fieldNames[0]) == null) { - fieldNameMap.put(fieldNames[0], new HashSet()); - } - fieldNameMap.get(fieldNames[0]).add(fieldNames[1]); - } - } - } - } - - mxgraph.getModel().beginUpdate(); - try { - // Make object edge in JGraphT and draw this in JGraphX. - Delta delta = eStructure.getDelta(); - int srcSideSize = delta.getSrcSide().size(); - int dstSideSize = delta.getDstSide().size(); - for (int i = srcSideSize - 1; i >= 0; i--) { - Reference ref = delta.getSrcSide().get(i); - if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { - for(String fieldName: fieldNameMap.get(ref.getSrcClassName())) { - // BUG : contains -> equals - if(ref.getDstClassName().contains(fieldName.toUpperCase())) { - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, fieldName, objectToVertexMap.get(ref.getSrcObjectId()).getCell(), objectToVertexMap.get(ref.getDstObjectId()).getCell()); - ((mxCell)edge).setStyle("exitX=1;exitY=1;exitPerimeter=1;entryX=0;entryY=0;entryPerimeter=1;"); - edgeMap.put(ref.getSrcClassName() + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); - break; - } - } - } - } - - for (int i = dstSideSize - 1; i >= 0; i--) { - Reference ref = delta.getDstSide().get(i); - if (!ref.isCreation() || !ref.getSrcObjectId().equals(ref.getDstObjectId())) { - for (String fieldName: fieldNameMap.get(ref.getSrcClassName())) { - // BUG : contains -> equals - if (ref.getDstClassName().contains(fieldName.toUpperCase())) { - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, fieldName, objectToVertexMap.get(ref.getSrcObjectId()).getCell(), objectToVertexMap.get(ref.getDstObjectId()).getCell()); - ((mxCell)edge).setStyle("exitX=0;exitY=1;exitPerimeter=1;entryX=1;entryY=0;entryPerimeter=1;"); - edgeMap.put(ref.getSrcClassName() + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); - break; - } - } - } - } - } finally { - mxgraph.getModel().endUpdate(); - } - } - - /** - * Make VertexMethodExecution. - * - * @param alias - */ - private void makeVertexMethodExecution(Alias alias) { - makeVertexMethodExecution(alias, alias.getMethodSignature(), alias.getMethodExecution()); - } - - /** - * Parent : Make VertexMethodExecution. - * - * @param alias - * @param methodSignature Called or this MethodSignature. - * @param methodExec Called or this MethodExecution. - */ - private void makeVertexMethodExecution(Alias alias, String methodSignature, MethodExecution methodExec) { - - if (methodSignature.contains(" ")) { - methodSignature = formatMethodSignature(methodSignature); - } - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - String objectId = alias.getObjectId(); - Object object = objectToVertexMap.get(objectId).getCell(); - double xCor = VERTEX_OBJECT_SIZE.getWidth() * 0.1; - double yCor = VERTEX_OBJECT_SIZE.getHeight() * 0.5; - int time = objectToVertexMap.get(objectId).getMethodExecutions().size(); - - Object vertex = mxgraph.insertDeltaVertex(object, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. - System.out.println((mxICell)vertex); - - VertexMethodExecution vertexMethodExecution = new VertexMethodExecution(methodSignature, vertex, xCor * (time + 1), yCor * (time + 1), VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); -// Object vertex = mxgraph.insertVertex(object, methodSignature, methodSignature, 0, 0, 0, 0, "fillColor=white", true); //creates a white vertex. -// Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. -// VertexMethodExecution vertexMethodExecution = new VertexMethodExecution(methodSignature, vertex, getXForCell(objectId) + (xCor * (time + 1)), getYForCell(objectId) + (yCor * (time + 1)), VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); - methodExecToVertexMap.put(methodExec, vertexMethodExecution); - if(methodExecToVertexMap.size() > 1) { - ((mxICell)vertex).setVisible(false); - } - objectToVertexMap.get(objectId).addMethodExecution(vertexMethodExecution); - } finally { - mxgraph.getModel().endUpdate(); - } - makeEdgeMethodExecution(); - } - - /** - * Remove VertexMethodExecution on AliasType is MethodInvocation of alias. - * - * @param alias - */ - private void removeVertexMethodExecution(Alias alias) { - // sourceVertex - VertexObject sourceVertexObject = objectToVertexMap.get(alias.getObjectId()); - MethodExecution methodExec = alias.getMethodExecution(); - - if(alias.getAliasType().equals(AliasType.METHOD_INVOCATION)) { - MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); - removeCalledVertexMethodExecution(sourceVertexObject, methodExec, calledMethodExec); - } else { - removeVertexMethodExecution(sourceVertexObject, methodExec); - } - } - - /** - * Remove VertexMethodExecution on AliasType is MethodInvocation of alias. - * - * @param sourceVertexObject - * @param methodExec - */ - private void removeVertexMethodExecution(VertexObject sourceVertexObject, MethodExecution methodExec) { - // Remove sourceVertex from Locals and Arguments Vertex of CalledMethodExecution's Vertex. - if (methodExecToVertexMap.containsKey(methodExec)) { - mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(methodExec).getCell(); - targetVertexCell.getParent().remove(targetVertexCell); - targetVertexCell.setParent(mxDefaultParent); - mxgraph.removeCells(new Object[] {targetVertexCell}); - objectToVertexMap.get(methodExec.getThisObjId()).getMethodExecutions().remove(methodExecToVertexMap.get(methodExec)); - methodExecToVertexMap.remove(methodExec); - edgeMap.remove(methodExec.getSignature()); - updateVertexObjectSize(); - } - } - - /** - * Remove CalledVertexMethodExecution on AliasType is MethodInvocation of alias. - * - * @param sourceVertexObject - * @param methodExec - * @param calledMethodExec - */ - private void removeCalledVertexMethodExecution(VertexObject sourceVertexObject, MethodExecution methodExec, MethodExecution calledMethodExec) { - - // Remove sourceVertex from Locals and Arguments Vertex of CalledMethodExecution's Vertex. - if (methodExecToVertexMap.containsKey(calledMethodExec)) { - mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(methodExec).getCell(); - mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(calledMethodExec).getCell(); - Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - mxgraph.getModel().beginUpdate(); - try { - mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); - try { - mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); - Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); - cloneTargetVertexCell.getGeometry().setX(absolutPointTargetVertexCell.getX()); - cloneTargetVertexCell.getGeometry().setY(absolutPointTargetVertexCell.getY()); - cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); - cloneTargetVertexCell.setValue(null); - Object tempEdge = mxgraph.insertEdge(mxDefaultParent, null, null, sourceVertexCell, cloneTargetVertexCell); - ((mxCell)tempEdge).setStyle("dashed=1;strokeColor=#008000;exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;endArrow=none"); - deltaAnimation.setReductionEdgeAnimation(cloneTargetVertexCell, new mxPoint(absolutPointSourceVertexCell.getX(), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight())); - deltaAnimation.startReductionEdgeAnimation(); -// deltaAnimation.setReductionEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); -// deltaAnimation.startReductionEdgeAnimation(); - mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - } finally { - mxgraph.getModel().endUpdate(); - } - - targetVertexCell.getParent().remove(targetVertexCell); - targetVertexCell.setParent(mxDefaultParent); - mxgraph.removeCells(new Object[] {targetVertexCell}); - objectToVertexMap.get(calledMethodExec.getThisObjId()).getMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExec)); - methodExecToVertexMap.get(calledMethodExec).getLocals().remove(sourceVertexObject); - methodExecToVertexMap.remove(calledMethodExec); - edgeMap.remove(methodExec.getSignature()); -// updateVertexObjectSize(); - } - } - - - /** Make EdgeMethodExecution. */ - private void makeEdgeMethodExecution() { - List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); - - // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology - mxgraph.getModel().beginUpdate(); - try { - // BUG : Edge Orientation Reverse. - for (int i = 0; i < methodExecList.size() - 1; i++) { - MethodExecution sourceMethodExec = methodExecList.get(i); - MethodExecution targetMethodExec = methodExecList.get(i + 1); - String methodSignature = sourceMethodExec.getSignature(); - if (!edgeMap.containsKey(methodSignature)) { - mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(sourceMethodExec).getCell(); - mxICell targetVertexCell = (mxICell)methodExecToVertexMap.get(targetMethodExec).getCell(); - Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); - Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); - -// System.out.println("start : " + sourceVertexCell.getGeometry().getCenterX() + ", " + (sourceVertexCell.getGeometry().getY() + sourceVertexCell.getGeometry().getHeight()) + ", " + targetVertexCell.getGeometry().getCenterX() + ", " + targetVertexCell.getGeometry().getY()); -// deltaAnimation.setEdgeAnimation(new mxPoint(sourceVertexCell.getGeometry().getCenterX(), sourceVertexCell.getGeometry().getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(targetVertexCell.getGeometry().getCenterX(), targetVertexCell.getGeometry().getY())); - deltaAnimation.setExpandEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); - deltaAnimation.startExpandEdgeAnimation(); - targetVertexCell.setVisible(true); - Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, methodSignature, null, sourceVertexCell, targetVertexCell); - ((mxCell)edge).setStyle("exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;"); - edgeMap.put(methodSignature, new Edge(methodSignature, TypeName.Call, edge)); - } - } - } finally { - mxgraph.getModel().endUpdate(); - } - } - - private int countChildVertex(VertexObject vertexObject) { - int time = vertexObject.getMethodExecutions().size(); - if(time == 0) { - return 1; - } - for(VertexMethodExecution vertexMethodExecution: vertexObject.getMethodExecutions()) { - for(VertexObject vo: vertexMethodExecution.getLocals()) { - time += countChildVertex(vo); - } - for(VertexObject vo: vertexMethodExecution.getArguments()) { - return countChildVertex(vo); - } - } - System.out.println(vertexObject.getLabel() + ": " + time); - return time; - } - - private String[] formatFieldName(String fieldName) { - String fieldNames[] = fieldName.split("\\."); - String names[] = new String[] {fieldNames[0], fieldNames[fieldNames.length - 1]}; - for(int i = 1; i < fieldNames.length - 1; i++) { - names[0] += "." + fieldNames[i]; - } - return names; - } - - private String formatMethodSignature(String methodSignature) { - // Step1 : split "(" - String[] methodSignatures = methodSignature.split("\\("); - methodSignature = methodSignatures[0]; - // Step2 : split " " - methodSignatures = methodSignature.split(" "); - methodSignature = methodSignatures[1]; - methodSignature += "()"; - return methodSignature; - } -} +package org.ntlab.deltaViewer; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.geom.Point2D; +import java.util.AbstractMap.SimpleEntry; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JFrame; + +import org.jgrapht.graph.DefaultEdge; +import org.jgrapht.graph.DirectedWeightedPseudograph; +import org.ntlab.deltaExtractor.Alias; +import org.ntlab.deltaExtractor.Delta; +import org.ntlab.deltaExtractor.ExtractedStructure; +import org.ntlab.deltaExtractor.ObjectIdPair; +import org.ntlab.deltaViewer.Edge.TypeName; +import org.ntlab.deltaExtractor.Alias.AliasType; +import org.ntlab.trace.ArrayAccess; +import org.ntlab.trace.FieldAccess; +import org.ntlab.trace.FieldUpdate; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.MethodInvocation; +import org.ntlab.trace.Reference; +import org.ntlab.trace.Statement; + +import com.mxgraph.model.mxCell; +import com.mxgraph.model.mxICell; +import com.mxgraph.swing.mxGraphComponent; +import com.mxgraph.util.mxConstants; +import com.mxgraph.util.mxPoint; +import com.mxgraph.view.mxGraphView; + +/** + * Make and display JGraph of extracted delta. + * + * @author Nitta Lab. + */ +//TASK: bArray O +//Careful: Parent +//BUG: methodExecution Id. O +//BUG: Move ObjectVertex position sometimes. O +//BUG: Resize ObjectVertex sometimes. O +//BUG: finally field reference. O +//BUG: edge drawing order. -> parent +//BUG: methodExecution drawing order. -> parent +//BUG: ObjectVertex position when Resize ObjectVertex. +public class DeltaViewer { + private static Dimension DEFAULT_SIZE = new Dimension(700, 700); + private static String WINDOW_TITLE = "Delta Viewer"; + + private ExtractedStructure eStructure; + private DeltaAliasCollector deltaAliasCollector; + + private Map objectToVertexMap = new HashMap<>(); + private Map methodExecToVertexMap = new LinkedHashMap<>(); + private Map edgeMap = new HashMap<>(); + + private JFrame frame; + private DeltaGraphAdapter mxgraph; + // No clue what this does but it is needed. + private mxICell mxDefaultParent; + + private mxGraphComponent mxgraphComponent; + + private int curFrame = 0; + private static Dimension VERTEX_OBJECT_SIZE = new Dimension(70, 70); + private static Dimension VERTEX_METHOD_EXECUTION_SIZE = new Dimension(55, 20); + private mxPoint coordinatorPoint = new mxPoint(DEFAULT_SIZE.getWidth() / 2 - 50, 100); + + private DeltaAnimation deltaAnimation; + + private double scale = 1; + + public DeltaViewer() { + mxgraph = new DeltaGraphAdapter(new DirectedWeightedPseudograph(DefaultEdge.class)); + mxDefaultParent = (mxCell)mxgraph.getDefaultParent(); + mxgraphComponent = new mxGraphComponent(mxgraph); + deltaAnimation = new DeltaAnimation(mxgraph, mxgraphComponent); + } + + public DeltaViewer(ExtractedStructure extractedStructure, DeltaAliasCollector deltaAliasCollector) { + this(); + this.eStructure = extractedStructure; + this.deltaAliasCollector = deltaAliasCollector; + // init(); + } + + /** Initialize JFrame, make vertex object and edge object. */ + public void init() { + // Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. + if(eStructure != null) { + WINDOW_TITLE = "extract delta of:" + eStructure.getDelta().getSrcSide().get(0).getDstClassName() + "(" + eStructure.getDelta().getSrcSide().get(0).getDstObjectId() + ")" + " -> " + eStructure.getDelta().getDstSide().get(0).getDstClassName() + "(" + eStructure.getDelta().getDstSide().get(0).getDstObjectId() + ")"; + } + + frame = new JFrame(WINDOW_TITLE); + frame.setSize(DEFAULT_SIZE); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + frame.add(mxgraphComponent, BorderLayout.CENTER); + frame.setVisible(true); + + createObjectVertices(eStructure); + createEdgeToObject(deltaAliasCollector.getAliasList(), deltaAliasCollector.getAliasToObjectPair()); + + // Fit graph size in visible JFrame. + mxGraphView view = mxgraphComponent.getGraph().getView(); + int componentWidth = mxgraphComponent.getWidth(); + double viewWidth = (double) view.getGraphBounds().getWidth(); + System.out.print("Scale " + componentWidth + ", " + viewWidth + ", " + coordinatorPoint.getX()); + if (viewWidth < coordinatorPoint.getX()) { + viewWidth += coordinatorPoint.getX(); + } + scale = (double)componentWidth/viewWidth; + System.out.println(", " + scale); + view.setScale(scale); + deltaAnimation.setScale(scale); + + update(); + } + + /** Update graph on JFrame and set Cell style. */ + public void update() { + setStyleOfCells(); + mxgraphComponent.refresh(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void setExtractedStructure(ExtractedStructure extractedStructure) { + this.eStructure = extractedStructure; + } + + public void setDeltaAliasCollector(DeltaAliasCollector deltaAliasCollector) { + this.deltaAliasCollector = deltaAliasCollector; + } + + public void setFrameSize(int width, int height) { + DEFAULT_SIZE.setSize(width, height); + } + + public void setCoordinatorPoint(double x, double y) { + coordinatorPoint.setX(x); + coordinatorPoint.setY(y); + } + + /** Set style of All cells. */ + private void setStyleOfCells() { + List vertexObject = new ArrayList<>(); + List alignMiddleVertex = new ArrayList<>(); + List alignTopVertex = new ArrayList<>(); + List edgeObject = new ArrayList<>(); + List edgeObjectCreate = new ArrayList<>(); + List edgeMethodExec = new ArrayList<>(); + List roundEdge = new ArrayList<>(); + + for (ObjectVertex vertex: objectToVertexMap.values()) { + vertexObject.add(vertex.getCell()); + if(vertex.getVertexMethodExecutions().size() == 0) { + alignMiddleVertex.add(vertex.getCell()); + } else { + alignTopVertex.add(vertex.getCell()); + } + } + + List vertexMethodExecList = new ArrayList<>(methodExecToVertexMap.values()); + Collections.reverse(vertexMethodExecList); + for (int i = 0; i < vertexMethodExecList.size(); i++) { + switch(i) { + case 0: + ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ff7fbf"); + break; + case 1: + ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ff99cc"); + break; + case 2: + ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffb2d8"); + break; + case 3: + ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffcce5"); + break; + case 4: + ((mxICell)vertexMethodExecList.get(i).getCell()).setStyle("fillColor=#ffe0ef"); + break; + default: + break; + } + } + + for (Edge edge: edgeMap.values()) { + roundEdge.add(edge.getCell()); + switch(edge.getTypeName()) { + case Reference: + edgeObject.add(edge.getCell()); + break; + case Create: + edgeObject.add(edge.getCell()); + edgeObjectCreate.add(edge.getCell()); + break; + case Call: + edgeMethodExec.add(edge.getCell()); + break; + default: + break; + } + } + + /*Given a cell, we can change it's style attributes, for example the color. NOTE that you have to call the graphComponent.refresh() function, otherwise you won't see the difference! */ + mxgraph.setCellStyles(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE, vertexObject.toArray(new Object[vertexObject.size()])); + mxgraph.setCellStyles(mxConstants.STYLE_PERIMETER, mxConstants.PERIMETER_ELLIPSE, vertexObject.toArray(new Object[vertexObject.size()])); + mxgraph.setCellStyleFlags(mxConstants.STYLE_FONTSTYLE, mxConstants.FONT_UNDERLINE, true, vertexObject.toArray(new Object[vertexObject.size()])); + mxgraph.setCellStyles(mxConstants.STYLE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE, alignMiddleVertex.toArray(new Object[alignMiddleVertex.size()])); + 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.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_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()])); + } + + // 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 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) { + return p1; + } + Point p2 = getAbsolutePointforCell(cell.getParent()); + return new Point((int) (p1.getX() + p2.getX()), (int) (p1.getY() + p2.getY())); + } + + /** + * Step to animation of specified alias. + * + * @param alias Alias type and occurrence point etc. + */ + public void stepToAnimation(Alias alias) { + try { + stepToAnimation(deltaAliasCollector.getAliasList().indexOf(alias)); + } catch (IndexOutOfBoundsException e) { + stepToAnimation(-1); + } + } + + /** + * Parent : Step to animation of specified numFrame. + * + * @param numFrame Current animation frame. + */ + public void stepToAnimation(int numFrame) { + if (deltaAliasCollector.getAliasList().size() > numFrame) { + doAnimation(curFrame, numFrame); + } else if (deltaAliasCollector.getAliasList().size() == numFrame){ + System.out.println("\r\nLast Animation."); + doLastAnimation(numFrame); + } else { + System.out.println("ERROR : Not exist alias."); + } + } + + /** + * Do animation from fromFrame to toFrame. + * + * @param fromFrame + * @param toFrame + */ + private void doAnimation(int fromFrame, int toFrame) { + for (int i = fromFrame; i <= toFrame; i++) { + List aliasList = new ArrayList<>(deltaAliasCollector.getAliasList()); + Alias alias = aliasList.get(i); + System.out.println("\r\n" + i + ": " + alias.getObjectId() + ", " + alias.getMethodSignature() + " l." + alias.getLineNo() + " : " + alias.getAliasType().toString()); + switch(alias.getAliasType()) { + case RETURN_VALUE: + moveObjectVertex(alias); + update(); + break; + case METHOD_INVOCATION: + removeMethodExecutionVertex(alias); + moveObjectVertex(alias); + update(); + break; + case CONSTRACTOR_INVOCATION: + createObjectVertexOnConstractor(alias); + createMethodExecutionVertex(alias, ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCallerSideMethodName(), ((MethodInvocation)alias.getOccurrencePoint().getStatement()).getCalledMethodExecution()); + update(); + removeMethodExecutionVertex(alias); + update(); + break; + case FORMAL_PARAMETER: + moveObjectVertex(alias); + update(); + break; + case ACTUAL_ARGUMENT: + moveObjectVertex(alias); + update(); + break; + case THIS: + if (curFrame == 0) { + createMethodExecutionVertex(alias); + update(); + } + break; + case RECEIVER: + // Make VertexMethodExecution of called method execution. + MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); + if (!methodExecToVertexMap.containsKey(calledMethodExec)) { + createMethodExecutionVertex(alias, calledMethodExec.getSignature(), calledMethodExec); + update(); + } + break; + default: + break; + } + curFrame = i + 1; + outputLog(); + } + } + + /** + * Make last animation of extracted delta. + * + * @param numFrame AliasList size. + */ + private void doLastAnimation(int numFrame) { + curFrame = numFrame; + Alias alias = deltaAliasCollector.getAliasList().get(numFrame - 1); + // Make ObjectEdge and reset position of vertexObject, remove vertexMethodExecution. + for(Statement statement: alias.getMethodExecution().getStatements()) { + if(statement instanceof FieldUpdate) { + // Format fieldName. + FieldUpdate fieldUpdateStatement = (FieldUpdate) statement; + String fieldNames[] = formatFieldName(fieldUpdateStatement.getFieldName()); + String fieldName = fieldNames[fieldNames.length-1]; + String sourceObjectId = fieldUpdateStatement.getContainerObjId(); + + createObjectRefrence(fieldUpdateStatement, fieldName); + removeCalledMethodExecutionVertex(objectToVertexMap.get(sourceObjectId), alias.getMethodExecution().getCallerMethodExecution(), alias.getMethodExecution()); + updateObjectVerticesSize(); + } + } + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); + Collections.reverse(methodExecList); + for(int i = 0; i < methodExecList.size(); i++) { + String objectId = methodExecList.get(i).getThisObjId(); + ObjectVertex sourceVertexObject = objectToVertexMap.get(objectId); // sourceVertex + MethodExecution methodExec = methodExecList.get(i); + if (i != methodExecList.size()-1) { + for(Statement statement: methodExec.getStatements()) { + if(statement instanceof MethodInvocation) { + MethodExecution calledMethodExec = ((MethodInvocation) statement).getCalledMethodExecution(); + String calledObjectId = calledMethodExec.getThisObjId(); + mxICell calledCell = (mxICell)objectToVertexMap.get(calledObjectId).getCell(); + Point absolutePointCalledCell = getAbsolutePointforCell(calledCell); + System.out.println(objectId + ", " + methodExec.getSignature()); + // objectToVertexMap.get(calledObjectId).resetCellPosition(); + if (methodExecToVertexMap.get(methodExec).getArguments().contains(objectToVertexMap.get(calledObjectId)) || methodExecToVertexMap.get(methodExec).getLocals().contains(objectToVertexMap.get(calledObjectId))) { + calledCell.getParent().remove(calledCell); + calledCell.setParent(mxDefaultParent); + calledCell.getGeometry().setX(absolutePointCalledCell.getX()); + calledCell.getGeometry().setY(absolutePointCalledCell.getY()); + deltaAnimation.setVertexAnimation(calledCell, new mxPoint(objectToVertexMap.get(calledObjectId).getInitialX(), objectToVertexMap.get(calledObjectId).getInitialY())); + deltaAnimation.startVertexAnimation(); + } + removeCalledMethodExecutionVertex(sourceVertexObject, methodExec.getCallerMethodExecution(), methodExec); + updateObjectVerticesSize(); + // removeVertexMethodExecution(sourceVertexObject, methodExec); + // update(); + break; + } + } + } else { + List arguments = new ArrayList<>(methodExecToVertexMap.get(methodExec).getArguments()); + List locals = new ArrayList<>(methodExecToVertexMap.get(methodExec).getLocals()); + if (arguments.size() != 0) { + for (ObjectVertex vo: arguments) { + mxICell cell = (mxICell)vo.getCell(); + Point absolutePointCell = getAbsolutePointforCell(cell); + cell.getParent().remove(cell); + cell.setParent(mxDefaultParent); + cell.getGeometry().setX(absolutePointCell.getX()); + cell.getGeometry().setY(absolutePointCell.getY()); + deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); + deltaAnimation.startVertexAnimation(); + methodExecToVertexMap.get(methodExec).getArguments().remove(vo); + } + }else if (locals.size() != 0) { + for (ObjectVertex vo: locals) { + mxICell cell = (mxICell)vo.getCell(); + Point absolutePointCell = getAbsolutePointforCell(cell); + cell.getParent().remove(cell); + cell.setParent(mxDefaultParent); + cell.getGeometry().setX(absolutePointCell.getX()); + cell.getGeometry().setY(absolutePointCell.getY()); + deltaAnimation.setVertexAnimation(cell, new mxPoint(vo.getInitialX(), vo.getInitialY())); + deltaAnimation.startVertexAnimation(); + methodExecToVertexMap.get(methodExec).getLocals().remove(vo); + } + } + updateObjectVerticesSize(); + } + } + } finally { + mxgraph.getModel().endUpdate(); + } + update(); + } + + /** Create ObjectVertices. */ + private void createObjectVertices(ExtractedStructure eStructure) { + while(coordinatorPoint.getX() - (150 * (eStructure.getDelta().getDstSide().size())) < 0) { + coordinatorPoint.setX(coordinatorPoint.getX() + 150); + } + + // ����(0, 0) + double xCor = coordinatorPoint.getX(); + double yCor = coordinatorPoint.getY(); + double time = 150; + + //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + // Draw vertex object. + // srcSide + Delta delta = eStructure.getDelta(); + int srcSideSize = delta.getSrcSide().size(); + for (int i = srcSideSize - 1; i >= 0; i--) { + Reference ref = delta.getSrcSide().get(i); + // System.out.println("srcSide: " + ref.getSrcClassName() + ", " + ref.isCreation()); + if (!ref.isCreation() && !ref.getSrcObjectId().equals(ref.getDstObjectId())) { + if(!objectToVertexMap.containsKey(ref.getSrcObjectId())) { + String srcClassName = ref.getSrcClassName(); + 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. + objectToVertexMap.put(ref.getSrcObjectId(), new ObjectVertex(ref.getSrcClassName(), vertex, xCor + (time * ((srcSideSize - 1) - i)), yCor + (time * ((srcSideSize - 1) - i)))); + } + if(!objectToVertexMap.containsKey(ref.getDstObjectId())) { + // System.out.println(ref.getDstClassName() + ", " + ref.isCreation()); + String dstClassName = ref.getDstClassName(); + 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. + objectToVertexMap.put(ref.getDstObjectId(), new ObjectVertex(ref.getDstClassName(), vertex, xCor + (time * (srcSideSize - i)), yCor + (time * (srcSideSize - i)))); + } + } + } + + // dstSide + int dstSideSize = delta.getDstSide().size(); + for (int i = dstSideSize - 1; i >= 0; i--) { + Reference ref = delta.getDstSide().get(i); + // System.out.println("dstSide: " + ref.getDstClassName() + ", " + ref.isCreation()); + if (!ref.isCreation() && !ref.getSrcObjectId().equals(ref.getDstObjectId())) { + String dstClassName = ref.getDstClassName(); + if (dstClassName.contains("[L")) { + dstClassName = formatArrayName(dstClassName); + } + Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, ref.getDstClassName(), dstClassName, xCor - (time * (dstSideSize - i)), yCor + (time * (dstSideSize - 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 * (dstSideSize - i)), yCor + (time * (dstSideSize - i)))); + } else { + objectToVertexMap.put(ref.getDstObjectId(), new ObjectVertex(ref.getDstClassName(), null, xCor - (time * (dstSideSize - i)), yCor + (time * (dstSideSize - i)))); + } + } + } finally { + mxgraph.getModel().endUpdate(); + } + } + + /** + * Create ObjectVertex when CONSTRACTOR_INVOCATION. + * @param alias + */ + private void createObjectVertexOnConstractor(Alias alias) { + ObjectVertex vertexObj = objectToVertexMap.get(alias.getObjectId()); + String souceObjId = alias.getMethodExecution().getThisObjId(); + mxICell sourceCell = (mxICell)objectToVertexMap.get(souceObjId).getCell(); + double sourceWidth = sourceCell.getGeometry().getWidth(); + double sourceHeight = sourceCell.getGeometry().getHeight(); + double overlapWidth = sourceWidth * Math.sqrt(2) * 0.1; + 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(); + 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. + vertexObj.setCell(vertex); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldName, null, sourceCell, vertex); + if(isSrcSideChanged) { + ((mxCell)edge).setStyle("exitX=1;exitY=1;exitPerimeter=1;entryX=0;entryY=0;entryPerimeter=1;"); + } else { + ((mxCell)edge).setStyle("exitX=0;exitY=1;exitPerimeter=1;entryX=1;entryY=0;entryPerimeter=1;"); + } + edgeMap.put(alias.getMethodExecution().getThisClassName() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); + setStyleOfCells(); + deltaAnimation.setVertexAnimation((mxICell)vertex, new mxPoint(vertexObj.getInitialX(), vertexObj.getInitialY())); + deltaAnimation.startVertexAnimation(); + } finally { + mxgraph.getModel().endUpdate(); + } + } + + private void createObjectRefrence(FieldUpdate fieldUpdateStatement, String fieldName) { + String sourceObjectId = fieldUpdateStatement.getContainerObjId(); + String targetObjectId = fieldUpdateStatement.getValueObjId(); + mxICell targetCell = (mxICell)objectToVertexMap.get(targetObjectId).getCell(); + Point absolutePointTargetCell = getAbsolutePointforCell(targetCell); + + targetCell.getParent().remove(targetCell); + targetCell.setParent(mxDefaultParent); + targetCell.getGeometry().setX(absolutePointTargetCell.getX()); + targetCell.getGeometry().setY(absolutePointTargetCell.getY()); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, fieldUpdateStatement.getFieldName(), fieldName, objectToVertexMap.get(sourceObjectId).getCell(), objectToVertexMap.get(targetObjectId).getCell()); + ((mxCell)edge).setStyle("exitX=0;exitY=0.5;exitPerimeter=1;entryX=1;entryY=0.5;entryPerimeter=1;"); + edgeMap.put(fieldUpdateStatement.getFieldName(), new Edge(fieldName, TypeName.Reference, edge)); + // System.out.println("last" + objectToVertexMap.get(targetObjectId).getInitialX() + ", " + objectToVertexMap.get(targetObjectId).getInitialY()); + deltaAnimation.setVertexAnimation(targetCell, new mxPoint(objectToVertexMap.get(targetObjectId).getInitialX(), objectToVertexMap.get(targetObjectId).getInitialY())); + deltaAnimation.startVertexAnimation(); + targetCell.getGeometry().setX(objectToVertexMap.get(targetObjectId).getInitialX()); + targetCell.getGeometry().setY(objectToVertexMap.get(targetObjectId).getInitialY()); + } + + /** + * SourceVertex move targetVertex. + * + * @param alias + */ + private void moveObjectVertex(Alias alias) { + // sourceVertex + ObjectVertex sourceObjectVertex = objectToVertexMap.get(alias.getObjectId()); + // targetVertex + MethodExecutionVertex targetMethodExecVertex = methodExecToVertexMap.get(alias.getMethodExecution()); + + moveObjectVertex(alias, sourceObjectVertex, targetMethodExecVertex); + updateObjectVerticesSize(); + } + + /** + * Parent : Source VertexObject move target VertexMethodExecution. + * + * @param alias + * @param sourceVertexObject Source VertexObject. + * @param targetVertexMethodExec Target VertexMethodExecution. + */ + private void moveObjectVertex(Alias alias, ObjectVertex sourceVertexObject, MethodExecutionVertex targetVertexMethodExec) { + MethodExecution methodExec = alias.getMethodExecution(); + if (alias.getAliasType().equals(AliasType.RETURN_VALUE) || alias.getAliasType().equals(AliasType.METHOD_INVOCATION)) { + moveLocalObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); + } else if (alias.getAliasType().equals(AliasType.FORMAL_PARAMETER)) { + moveArgumentObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); + } else if (alias.getAliasType().equals(AliasType.ACTUAL_ARGUMENT)) { + moveActualArgumentObjectVertex(methodExec, sourceVertexObject, targetVertexMethodExec); + } + } + + /** + * Source VertexObject move target VertexMethodExecution to Local position from caller MethodExecution. + * + * @param callerMethodExec Caller MethodExecution. + * @param sourceVertexObject + * @param targetVertexMethodExec + */ + private void moveLocalObjectVertex(MethodExecution callerMethodExec, ObjectVertex sourceVertexObject, MethodExecutionVertex targetVertexMethodExec) { + mxICell sourceCell = (mxICell)sourceVertexObject.getCell(); + mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); + // mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); + + // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. + // MethodExecution callercallerMethodExec = callerMethodExec.getCallerMethodExecution(); + // System.out.println(callerMethodExec.getSignature()); + // if (methodExecToVertexMap.containsKey(callercallerMethodExec) && methodExecToVertexMap.get(callercallerMethodExec).getLocals().contains(sourceVertexObject)) { + // methodExecToVertexMap.get(callercallerMethodExec).getLocals().remove(sourceVertexObject); + // System.out.println(methodExecToVertexMap.get(callercallerMethodExec).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); + // } + // + // if (methodExecToVertexMap.containsKey(callercallerMethodExec) && methodExecToVertexMap.get(callercallerMethodExec).getArguments().contains(sourceVertexObject)) { + // methodExecToVertexMap.get(callercallerMethodExec).getArguments().remove(sourceVertexObject); + // System.out.println(methodExecToVertexMap.get(callercallerMethodExec).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); + // } + if (methodExecToVertexMap.containsKey(callerMethodExec) && methodExecToVertexMap.get(callerMethodExec).getLocals().contains(sourceVertexObject)) { + methodExecToVertexMap.get(callerMethodExec).getLocals().remove(sourceVertexObject); + System.out.println(methodExecToVertexMap.get(callerMethodExec).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); + } + + if (methodExecToVertexMap.containsKey(callerMethodExec) && methodExecToVertexMap.get(callerMethodExec).getArguments().contains(sourceVertexObject)) { + methodExecToVertexMap.get(callerMethodExec).getArguments().remove(sourceVertexObject); + System.out.println(methodExecToVertexMap.get(callerMethodExec).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); + } + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + int time = targetVertexMethodExec.getLocals().size() + 1; + double sourceX = sourceCell.getGeometry().getX(); + double sourceY = sourceCell.getGeometry().getY(); + + // System.out.println(time); + + if(sourceCell.getParent().getValue() != null) { + Point absolutePointSourceCell = getAbsolutePointforCell(sourceCell); + sourceX = absolutePointSourceCell.getX(); + sourceY = absolutePointSourceCell.getY(); + sourceCell.getParent().remove(sourceCell); + } + + sourceCell.setParent(targetCell.getParent()); + targetCell.getParent().insert(sourceCell); + + Point absolutePointTargetCell = getAbsolutePointforCell(sourceCell.getParent()); + sourceCell.getGeometry().setX(sourceX - absolutePointTargetCell.getX()); + sourceCell.getGeometry().setY(sourceY - absolutePointTargetCell.getY()); + + double sourceWidth = sourceCell.getGeometry().getWidth(); + double sourceHeight = sourceCell.getGeometry().getHeight(); + double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); + double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); + + deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); + deltaAnimation.startVertexAnimation(); + + sourceCell.setParent(targetCell.getParent()); + targetCell.getParent().insert(sourceCell); + sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth); + sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); + targetVertexMethodExec.getLocals().add(sourceVertexObject); + System.out.println("moveLocalObjectVertex: " + targetVertexMethodExec.getLabel() + " :Local: " + sourceVertexObject.getLabel()); + } finally { + mxgraph.getModel().endUpdate(); + } + } + + /** + * Source VertexObject move target VertexMethodExecution to Argument position from MethodExecution. + * + * @param methodExec MethodExecution. + * @param sourceVertexObject + * @param targetVertexMethodExec + */ + private void moveArgumentObjectVertex(MethodExecution methodExec, ObjectVertex sourceVertexObject, MethodExecutionVertex targetVertexMethodExec) { + mxICell sourceCell = (mxICell)sourceVertexObject.getCell(); + mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); + // mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); + + // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. + MethodExecution callerMethodExecution = methodExec.getCallerMethodExecution(); + if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getLocals().contains(sourceVertexObject)) { + methodExecToVertexMap.get(callerMethodExecution).getLocals().remove(sourceVertexObject); + System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); + } + + if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getArguments().contains(sourceVertexObject)) { + methodExecToVertexMap.get(callerMethodExecution).getArguments().remove(sourceVertexObject); + System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); + } + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + int time = targetVertexMethodExec.getArguments().size(); + double sourceX = sourceCell.getGeometry().getX(); + double sourceY = sourceCell.getGeometry().getY(); + + // System.out.println(time); + + if(sourceCell.getParent().getValue() != null) { + Point absolutePointSourceCell = getAbsolutePointforCell(sourceCell); + sourceX = absolutePointSourceCell.getX(); + sourceY = absolutePointSourceCell.getY(); + sourceCell.getParent().remove(sourceCell); + } + + sourceCell.setParent(targetCell.getParent()); + targetCell.getParent().insert(sourceCell); + sourceCell.getGeometry().setX(sourceX - sourceCell.getParent().getGeometry().getX()); + sourceCell.getGeometry().setY(sourceY - sourceCell.getParent().getGeometry().getY()); + + double sourceWidth = sourceCell.getGeometry().getWidth(); + double sourceHeight = sourceCell.getGeometry().getHeight(); + double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); + double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); + + deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); + deltaAnimation.startVertexAnimation(); + + // sourceCell.setParent(targetCell.getParent()); + // targetCell.getParent().insert(sourceCell); + sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth); + sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); + targetVertexMethodExec.getArguments().add(sourceVertexObject); + System.out.println("moveArgumentObejctVertex" + targetVertexMethodExec.getLabel() + " :Argument: " + sourceVertexObject.getLabel()); + } finally { + mxgraph.getModel().endUpdate(); + } + } + + /** + * Source VertexObject move target VertexMethodExecution to Argument position from MethodExecution. + * + * @param methodExec MethodExecution. + * @param sourceVertexObject + * @param targetVertexMethodExec + */ + private void moveActualArgumentObjectVertex(MethodExecution methodExec, ObjectVertex sourceVertexObject, MethodExecutionVertex targetVertexMethodExec) { + mxICell sourceCell = (mxICell)sourceVertexObject.getCell(); + mxICell targetCell = (mxICell) targetVertexMethodExec.getCell(); + // mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); + + // Remove sourceVertex from Locals and Arguments Vertex of MethodExecution's Vertex. + // MethodExecution callerMethodExecution = methodExec.getCallerMethodExecution(); + System.out.println(methodExec.getSignature()); + System.out.println(sourceVertexObject.getLabel()); + // if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getLocals().contains(sourceVertexObject)) { + // methodExecToVertexMap.get(callerMethodExecution).getLocals().remove(sourceVertexObject); + // System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); + // } + // + // if (methodExecToVertexMap.containsKey(callerMethodExecution) && methodExecToVertexMap.get(callerMethodExecution).getArguments().contains(sourceVertexObject)) { + // methodExecToVertexMap.get(callerMethodExecution).getArguments().remove(sourceVertexObject); + // System.out.println(methodExecToVertexMap.get(callerMethodExecution).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); + // } + if (methodExecToVertexMap.containsKey(methodExec) && methodExecToVertexMap.get(methodExec).getLocals().contains(sourceVertexObject)) { + methodExecToVertexMap.get(methodExec).getLocals().remove(sourceVertexObject); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeLocal: " + sourceVertexObject.getLabel()); + } + + if (methodExecToVertexMap.containsKey(methodExec) && methodExecToVertexMap.get(methodExec).getArguments().contains(sourceVertexObject)) { + methodExecToVertexMap.get(methodExec).getArguments().remove(sourceVertexObject); + System.out.println(methodExecToVertexMap.get(methodExec).getLabel() + " :removeArgument: " + sourceVertexObject.getLabel()); + } + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + // int time = targetVertexMethodExec.getArguments().size(); + int time = targetVertexMethodExec.getLocals().size() + 1; + double sourceX = sourceCell.getGeometry().getX(); + double sourceY = sourceCell.getGeometry().getY(); + + System.out.println(time + ", " + targetVertexMethodExec.getLocals().size()); + // if (time == 0) time = 1; + + if(sourceCell.getParent().getValue() != null) { + Point absolutePointSourceCell = getAbsolutePointforCell(sourceCell); + sourceX = absolutePointSourceCell.getX(); + sourceY = absolutePointSourceCell.getY(); + sourceCell.getParent().remove(sourceCell); + } + + sourceCell.setParent(targetCell.getParent()); + targetCell.getParent().insert(sourceCell); + sourceCell.getGeometry().setX(sourceX - sourceCell.getParent().getGeometry().getX()); + sourceCell.getGeometry().setY(sourceY - sourceCell.getParent().getGeometry().getY()); + + double sourceWidth = sourceCell.getGeometry().getWidth(); + double sourceHeight = sourceCell.getGeometry().getHeight(); + double overlapWidth = sourceWidth - (sourceWidth * Math.sqrt(2) * 0.1); + double overlapHeight = sourceHeight - (sourceHeight * Math.sqrt(2) * 0.1); + + deltaAnimation.setVertexAnimation(sourceCell, new mxPoint(targetCell.getGeometry().getX() - overlapWidth, targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time))); + deltaAnimation.startVertexAnimation(); + sourceCell.getGeometry().setX(targetCell.getGeometry().getX() - overlapWidth); + sourceCell.getGeometry().setY(targetCell.getGeometry().getY() - overlapHeight + (sourceHeight * time)); + targetVertexMethodExec.getArguments().add(sourceVertexObject); + System.out.println("moveActualArgumentObjectVertex: " + targetVertexMethodExec.getLabel() + " :Argument: " + sourceVertexObject.getLabel()); + } finally { + mxgraph.getModel().endUpdate(); + } + } + + // private void moveInitialObjectVertex(MethodExecution methodExecution) { + // for(Statement statement: methodExecution.getStatements()) { + // if(statement instanceof MethodInvocation) { + // // moveInitialVertexObject((MethodInvocation) statement); + // MethodExecution calledMethodExec = ((MethodInvocation)statement).getCalledMethodExecution(); + // String calledObjectId = calledMethodExec.getThisObjId(); + // mxICell calledCell = (mxICell)objectToVertexMap.get(calledObjectId).getCell(); + // Point absolutePointCalledCell = getAbsolutePointforCell(calledCell); + // // System.out.println(objectId + ", " + methodExec.getSignature()); + // // objectToVertexMap.get(calledObjectId).resetCellPosition(); + // if (methodExecToVertexMap.get(methodExecution).getArguments().contains(objectToVertexMap.get(calledObjectId)) || methodExecToVertexMap.get(methodExecution).getLocals().contains(objectToVertexMap.get(calledObjectId))) { + // calledCell.getParent().remove(calledCell); + // calledCell.setParent(mxDefaultParent); + // calledCell.getGeometry().setX(absolutePointCalledCell.getX()); + // calledCell.getGeometry().setY(absolutePointCalledCell.getY()); + // deltaAnimation.setVertexAnimation(calledCell, new mxPoint(objectToVertexMap.get(calledObjectId).getInitialX(), objectToVertexMap.get(calledObjectId).getInitialY())); + // deltaAnimation.startVertexAnimation(); + // break; + // } + // } + // } + // } + + /** Update ObjectVertices size. */ + private void updateObjectVerticesSize() { + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology + mxgraph.getModel().beginUpdate(); + try { + for (ObjectVertex vertexObject: objectToVertexMap.values()) { + mxCell vertexObjectCell = ((mxCell) vertexObject.getCell()); + int time = vertexObjectCell.getChildCount(); + if (time == 0) { + time = 1; + } + // System.out.println("updateVertexObjectSize: " + vertexObjectCell.getGeometry().getWidth() + "->" + VERTEX_OBJECT_SIZE.getWidth() * time+ ", " + vertexObjectCell.getId()); + if(vertexObjectCell.getGeometry().getWidth() != VERTEX_OBJECT_SIZE.getWidth() * time) { + System.out.println("updateVertexObjectSize: " + vertexObjectCell.getGeometry().getWidth() + "->" + VERTEX_OBJECT_SIZE.getWidth() * time+ ", " + vertexObjectCell.getId()); + Dimension targetDimension = new Dimension(); + targetDimension.setSize(VERTEX_OBJECT_SIZE.getWidth() * time, VERTEX_OBJECT_SIZE.getHeight() * time); + // if (vertexObjectCell.getParent() != mxDefaultParent && vertexObjectCell.getChildCount() != 0) { + // mxPoint targetPoint = new mxPoint(vertexObjectCell.getGeometry().getX() - (targetDimension.getWidth() - vertexObjectCell.getGeometry().getWidth()) / 2, vertexObjectCell.getGeometry().getY() + (targetDimension.getHeight() - vertexObjectCell.getGeometry().getHeight()) / 2); + // deltaAnimation.setVertexAnimation(vertexObjectCell, targetPoint); + // deltaAnimation.startVertexAnimation(); + // } + deltaAnimation.setResizeVertexAnimation(vertexObjectCell, targetDimension); + deltaAnimation.startResizeVertexAnimation(); + } + } + }finally { + mxgraph.getModel().endUpdate(); + } + } + + /** + * Update VertexObject of targetMethodExecCell size have sourceObjectCell. + * + * @param sourceObjectCell + * @param targetMethodExecCell + */ + // private void updateVertexObjectSize(mxICell sourceObjectCell, mxICell targetMethodExecCell) { + // mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); + // + // //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + // mxgraph.getModel().beginUpdate(); + // try { + // double preX = parentTargetMethodExecCell.getGeometry().getX(); + // double preY = parentTargetMethodExecCell.getGeometry().getY(); + // double preCenterX = parentTargetMethodExecCell.getGeometry().getCenterX(); + // double preCenterY = parentTargetMethodExecCell.getGeometry().getCenterY(); + // parentTargetMethodExecCell.getGeometry().setWidth(parentTargetMethodExecCell.getGeometry().getWidth() * 1.8); + // parentTargetMethodExecCell.getGeometry().setHeight(parentTargetMethodExecCell.getGeometry().getHeight() * 1.8); + // parentTargetMethodExecCell.getGeometry().setX(preX - (parentTargetMethodExecCell.getGeometry().getCenterX() - preCenterX)); + // parentTargetMethodExecCell.getGeometry().setY(preY - (parentTargetMethodExecCell.getGeometry().getCenterY() - preCenterY)); + // } finally { + // mxgraph.getModel().endUpdate(); + // } + // } + + /** + * Create MethodExecutionVertex. + * + * @param alias + */ + private void createMethodExecutionVertex(Alias alias) { + createMethodExecutionVertex(alias, alias.getMethodSignature(), alias.getMethodExecution()); + } + + /** + * Parent : Create MethodExecutionVertex. + * + * @param alias + * @param methodSignature Called or this MethodSignature. + * @param methodExec Called or this MethodExecution. + */ + private void createMethodExecutionVertex(Alias alias, String methodSignature, MethodExecution methodExec) { + + if (methodSignature.contains(" ")) { + System.out.println(methodSignature); + methodSignature = formatMethodSignature(methodSignature); + } + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + String objectId = alias.getObjectId(); + Object object = objectToVertexMap.get(objectId).getCell(); + double xCor = VERTEX_OBJECT_SIZE.getWidth() * 0.1; + double yCor = VERTEX_OBJECT_SIZE.getHeight() * 0.5; + int time = objectToVertexMap.get(objectId).getVertexMethodExecutions().size(); + + Object vertex = mxgraph.insertDeltaVertex(object, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. + System.out.println("makeVertexMethodExecution: " + ((mxICell)vertex).getId() + " (" + xCor * (time + 1) + ", " + yCor * (time + 1) + ")"); + + MethodExecutionVertex vertexMethodExecution = new MethodExecutionVertex(methodSignature, vertex, xCor , yCor * (time + 1), VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); + // Object vertex = mxgraph.insertVertex(object, methodSignature, methodSignature, 0, 0, 0, 0, "fillColor=white", true); //creates a white vertex. + // Object vertex = mxgraph.insertDeltaVertex(mxDefaultParent, methodSignature, methodSignature, "fillColor=white"); //creates a white vertex. + // VertexMethodExecution vertexMethodExecution = new VertexMethodExecution(methodSignature, vertex, getXForCell(objectId) + (xCor * (time + 1)), getYForCell(objectId) + (yCor * (time + 1)), VERTEX_METHOD_EXECUTION_SIZE.getWidth(), VERTEX_METHOD_EXECUTION_SIZE.getHeight()); + methodExecToVertexMap.put(methodExec, vertexMethodExecution); + if(methodExecToVertexMap.size() > 1) { + ((mxICell)vertex).setVisible(false); + createEdgeToMethodExecution(); + } + objectToVertexMap.get(objectId).addMethodExecution(vertexMethodExecution); + } finally { + mxgraph.getModel().endUpdate(); + } + setStyleOfCells(); + } + + /** + * Remove VertexMethodExecution on AliasType is MethodInvocation of alias. + * + * @param alias + */ + private void removeMethodExecutionVertex(Alias alias) { + // sourceVertex + ObjectVertex sourceVertexObject = objectToVertexMap.get(alias.getObjectId()); + MethodExecution methodExec = alias.getMethodExecution(); + + if(alias.getAliasType().equals(AliasType.METHOD_INVOCATION) || alias.getAliasType().equals(AliasType.CONSTRACTOR_INVOCATION)) { + MethodExecution calledMethodExec = ((MethodInvocation) alias.getOccurrencePoint().getStatement()).getCalledMethodExecution(); + removeCalledMethodExecutionVertex(sourceVertexObject, methodExec, calledMethodExec); + } else { + removeMethodExecutionVertex(sourceVertexObject, methodExec); + } + } + + /** + * Remove VertexMethodExecution on AliasType is MethodInvocation of alias. + * + * @param sourceVertexObject + * @param methodExec + */ + private void removeMethodExecutionVertex(ObjectVertex sourceVertexObject, MethodExecution methodExec) { + // Remove sourceVertex from Locals and Arguments Vertex of CalledMethodExecution's Vertex. + if (methodExecToVertexMap.containsKey(methodExec)) { + mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(methodExec).getCell(); + targetVertexCell.getParent().remove(targetVertexCell); + targetVertexCell.setParent(mxDefaultParent); + mxgraph.removeCells(new Object[] {targetVertexCell}); + objectToVertexMap.get(methodExec.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(methodExec)); + methodExecToVertexMap.remove(methodExec); + edgeMap.remove(methodExec.getSignature()); + updateObjectVerticesSize(); + } + } + + /** + * Remove CalledVertexMethodExecution on AliasType is MethodInvocation of alias. + * + * @param sourceVertexObject + * @param methodExec + * @param calledMethodExec + */ + private void removeCalledMethodExecutionVertex(ObjectVertex sourceVertexObject, MethodExecution methodExec, MethodExecution calledMethodExec) { + + // Remove sourceVertex from Locals and Arguments Vertex of CalledMethodExecution's Vertex. + if (methodExecToVertexMap.containsKey(calledMethodExec)) { + mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(methodExec).getCell(); + mxCell targetVertexCell = (mxCell)methodExecToVertexMap.get(calledMethodExec).getCell(); + Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + mxgraph.getModel().beginUpdate(); + try { + mxgraph.removeCells(mxgraph.getEdgesBetween(sourceVertexCell, targetVertexCell)); + try { + mxICell cloneTargetVertexCell = (mxICell) mxgraph.addCell(targetVertexCell.clone()); + Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); + cloneTargetVertexCell.getGeometry().setX(absolutPointTargetVertexCell.getX()); + cloneTargetVertexCell.getGeometry().setY(absolutPointTargetVertexCell.getY()); + cloneTargetVertexCell.setStyle("fillColor=none;strokeColor=none;fontColor=#008000;"); + cloneTargetVertexCell.setValue(null); + Object tempEdge = mxgraph.insertEdge(mxDefaultParent, null, null, sourceVertexCell, cloneTargetVertexCell); + ((mxCell)tempEdge).setStyle("dashed=1;strokeColor=#008000;exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;endArrow=none"); + deltaAnimation.setReductionEdgeAnimation(cloneTargetVertexCell, new mxPoint(absolutPointSourceVertexCell.getX(), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight())); + deltaAnimation.startReductionEdgeAnimation(); + // deltaAnimation.setReductionEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); + // deltaAnimation.startReductionEdgeAnimation(); + mxgraph.removeCells(new Object[]{cloneTargetVertexCell}); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } finally { + mxgraph.getModel().endUpdate(); + } + ((mxCell)targetVertexCell.getParent()).remove(targetVertexCell); + targetVertexCell.setParent(mxDefaultParent); + mxgraph.removeCells(new Object[] {targetVertexCell}); + objectToVertexMap.get(calledMethodExec.getThisObjId()).getVertexMethodExecutions().remove(methodExecToVertexMap.get(calledMethodExec)); + methodExecToVertexMap.get(calledMethodExec).getLocals().remove(sourceVertexObject); + methodExecToVertexMap.remove(calledMethodExec); + edgeMap.remove(methodExec.getSignature()); + // moveInitialVertexObject(methodExec); + // updateObjectVerticesSize(); + } + } + + + /** + * Update VertexObject of targetMethodExecCell size have sourceObjectCell. + * + * @param sourceObjectCell + * @param targetMethodExecCell + */ + // private void updateVertexObjectSize(mxICell sourceObjectCell, mxICell targetMethodExecCell) { + // mxICell parentTargetMethodExecCell = targetMethodExecCell.getParent(); + // + // //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + // mxgraph.getModel().beginUpdate(); + // try { + // double preX = parentTargetMethodExecCell.getGeometry().getX(); + // double preY = parentTargetMethodExecCell.getGeometry().getY(); + // double preCenterX = parentTargetMethodExecCell.getGeometry().getCenterX(); + // double preCenterY = parentTargetMethodExecCell.getGeometry().getCenterY(); + // parentTargetMethodExecCell.getGeometry().setWidth(parentTargetMethodExecCell.getGeometry().getWidth() * 1.8); + // parentTargetMethodExecCell.getGeometry().setHeight(parentTargetMethodExecCell.getGeometry().getHeight() * 1.8); + // parentTargetMethodExecCell.getGeometry().setX(preX - (parentTargetMethodExecCell.getGeometry().getCenterX() - preCenterX)); + // parentTargetMethodExecCell.getGeometry().setY(preY - (parentTargetMethodExecCell.getGeometry().getCenterY() - preCenterY)); + // } finally { + // mxgraph.getModel().endUpdate(); + // } + // } + + /** Make edge object in JGraphT and draw this in JGraphX. + * @param map + * @param collection */ + private void createEdgeToObject(List aliasList, Map aliasToObjIdPair) { + for (int i = 0; i < aliasList.size()-1; i++) { + Alias curAlias = aliasList.get(i); + Alias nextAlias = aliasList.get(i+1); + String srcClassName = null; + String fieldName = null; + + if (curAlias.getAliasType().equals(AliasType.THIS) /*&& nextAlias.getAliasType().equals(AliasType.FIELD)*/) { + if (nextAlias.getAliasType().equals(AliasType.RETURN_VALUE)) { + MethodExecution nextMethodExec = nextAlias.getMethodExecution(); + //Array��List�̂Ƃ��������x����t����i�m���ɕ������Ă�����̂Ƃ�)getSignature->contains("List.get(") || "Map.get(") <�z���C�g���X�g> + if (nextMethodExec.getSignature().contains("List.get(") || + nextMethodExec.getSignature().contains("Map.get(")) { + srcClassName = nextMethodExec.getThisClassName(); + fieldName = nextMethodExec.getArguments().get(0).getId(); + System.out.println("rTHIS " + srcClassName + ", " +nextMethodExec.getArguments().get(0).getId()); + } + } else { + Statement statement = nextAlias.getOccurrencePoint().getStatement(); + if(statement instanceof FieldAccess) { + String fieldNames[] = formatFieldName(((FieldAccess)statement).getFieldName()); + srcClassName = fieldNames[0]; + fieldName = fieldNames[1]; + } + } + System.out.println("THIS " + srcClassName + "(" + curAlias.getObjectId() + ") -> " + "(" + nextAlias.getObjectId() + "), "+ fieldName); + } + if(curAlias.getAliasType().equals(AliasType.ARRAY)) { + Statement statement= nextAlias.getOccurrencePoint().getStatement(); + if(statement instanceof ArrayAccess) { + srcClassName = ((ArrayAccess)statement).getArrayClassName(); + int index = ((ArrayAccess)statement).getIndex(); + fieldName = formatArrayIndex(index); + System.out.println("ARRAY " + srcClassName + "(" + curAlias.getObjectId() + ") -> " + "(" + nextAlias.getObjectId() + "), " + fieldName); + } + } + if (srcClassName != null && fieldName != null && srcClassName != null) { + // 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(); + // String dstClassName = curAlias.getMethodExecution().getThisClassName(); + System.out.println("makeEdgeObject: " + fieldName + ", " + srcClassName/* + ", " + dstClassName*/); + 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;"); + } else { + ((mxCell)edge).setStyle("exitX=0;exitY=1;exitPerimeter=1;entryX=1;entryY=0;entryPerimeter=1;"); + } + edgeMap.put(srcClassName + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); + } finally { + mxgraph.getModel().endUpdate(); + } + } + } + } + + /** Make EdgeMethodExecution. */ + private void createEdgeToMethodExecution() { + List methodExecList = new ArrayList<>(methodExecToVertexMap.keySet()); + + // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology + mxgraph.getModel().beginUpdate(); + try { + // BUG : Edge Orientation Reverse. + for (int i = 0; i < methodExecList.size() - 1; i++) { + MethodExecution sourceMethodExec = methodExecList.get(i); + MethodExecution targetMethodExec = methodExecList.get(i + 1); + String methodSignature = sourceMethodExec.getSignature(); + if (!edgeMap.containsKey(methodSignature)) { + mxICell sourceVertexCell = (mxICell)methodExecToVertexMap.get(sourceMethodExec).getCell(); + mxICell targetVertexCell = (mxICell)methodExecToVertexMap.get(targetMethodExec).getCell(); + Point absolutPointSourceVertexCell = getAbsolutePointforCell(sourceVertexCell); + Point absolutPointTargetVertexCell = getAbsolutePointforCell(targetVertexCell); + + // System.out.println("start : " + sourceVertexCell.getGeometry().getCenterX() + ", " + (sourceVertexCell.getGeometry().getY() + sourceVertexCell.getGeometry().getHeight()) + ", " + targetVertexCell.getGeometry().getCenterX() + ", " + targetVertexCell.getGeometry().getY()); + // deltaAnimation.setEdgeAnimation(new mxPoint(sourceVertexCell.getGeometry().getCenterX(), sourceVertexCell.getGeometry().getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(targetVertexCell.getGeometry().getCenterX(), targetVertexCell.getGeometry().getY())); + deltaAnimation.setExpandEdgeAnimation(new mxPoint(absolutPointSourceVertexCell.getX() + (sourceVertexCell.getGeometry().getWidth() / 2), absolutPointSourceVertexCell.getY() + sourceVertexCell.getGeometry().getHeight()), new mxPoint(absolutPointTargetVertexCell.getX() + (targetVertexCell.getGeometry().getWidth() / 2), absolutPointTargetVertexCell.getY())); + deltaAnimation.startExpandEdgeAnimation(); + targetVertexCell.setVisible(true); + Object edge = mxgraph.insertDeltaEdge(mxDefaultParent, methodSignature, null, sourceVertexCell, targetVertexCell); + ((mxCell)edge).setStyle("exitX=0.5;exitY=1;exitPerimeter=1;entryX=0.5;entryY=0;entryPerimeter=1;"); + edgeMap.put(methodSignature, new Edge(methodSignature, TypeName.Call, edge)); + } + } + } finally { + mxgraph.getModel().endUpdate(); + } + } + + private int countChildVertex(ObjectVertex vertexObject) { + int time = vertexObject.getVertexMethodExecutions().size(); + if(time == 0) { + return 1; + } + for(MethodExecutionVertex vertexMethodExecution: vertexObject.getVertexMethodExecutions()) { + for(ObjectVertex vo: vertexMethodExecution.getLocals()) { + time += countChildVertex(vo); + } + for(ObjectVertex vo: vertexMethodExecution.getArguments()) { + return countChildVertex(vo); + } + } + System.out.println(vertexObject.getLabel() + ": " + time); + return time; + } + + private String[] formatFieldName(String fieldName) { + String fieldNames[] = fieldName.split("\\."); + String names[] = new String[] {fieldNames[0], fieldNames[fieldNames.length - 1]}; + for(int i = 1; i < fieldNames.length - 1; i++) { + names[0] += "." + fieldNames[i]; + } + return names; + } + + private String formatMethodSignature(String methodSignature) { + // Step1 : split "(" + String[] methodSignatures = methodSignature.split("\\("); + methodSignature = methodSignatures[0]; + // Step2 : split " " + methodSignatures = methodSignature.split(" "); + StringBuffer sb = new StringBuffer(); + sb.append(methodSignatures[methodSignatures.length-1]); + sb.append("()"); + return sb.toString(); + } + + private String formatArrayName(String srcClassName) { + // Step1 : remove "[L" + StringBuffer sb = new StringBuffer(); + sb.append(srcClassName.substring(2, srcClassName.length()-1)); + sb.append("[]"); + return sb.toString(); + } + + private String formatArrayIndex(int index) { + StringBuffer sb = new StringBuffer(); + sb.append("["); + sb.append(index); + sb.append("]"); + return sb.toString(); + } + + private void outputLog() { + for (Object object: mxgraph.getChildCells(mxDefaultParent)) { + System.out.println(object); + for (int i = 0; i < ((mxICell)object).getChildCount(); i++) { + System.out.println(" " + ((mxICell)object).getChildAt(i)); + } + } + System.out.println("\nObject"); + for (ObjectVertex vo: objectToVertexMap.values()) { + System.out.println(vo.getLabel()); + for (MethodExecutionVertex vme: vo.getVertexMethodExecutions()) { + System.out.println(" " + vme.getLabel()); + for (ObjectVertex vmevo: vme.getArguments()) { + System.out.println(" Argument: " + vmevo.getLabel()); + } + for (ObjectVertex vmevo: vme.getLocals()) { + System.out.println(" Local: " + vmevo.getLabel()); + } + } + } + System.out.println("\nEdge"); + for (Edge e: edgeMap.values()) { + System.out.println(e.getLabel()); + System.out.println(" " + ((mxICell)e.getCell()).getParent().getId()); + } + } +} diff --git a/src/org/ntlab/deltaViewer/DeltaViewerSample.java b/src/org/ntlab/deltaViewer/DeltaViewerSample.java new file mode 100644 index 0000000..ad803b4 --- /dev/null +++ b/src/org/ntlab/deltaViewer/DeltaViewerSample.java @@ -0,0 +1,647 @@ +package org.ntlab.deltaViewer; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +import org.ntlab.deltaExtractor.Alias; +import org.ntlab.deltaExtractor.DeltaExtractorJSON; +import org.ntlab.deltaExtractor.ExtractedStructure; +import org.ntlab.trace.FieldAccess; +import org.ntlab.trace.MethodExecution; +import org.ntlab.trace.Reference; +import org.ntlab.trace.Statement; +import org.ntlab.trace.ThreadInstance; +import org.ntlab.trace.TraceJSON; +import org.ntlab.trace.TracePoint; + +/** + * Delta viewer sample for MagnetRON. + * + * @author Nitta Lab. + */ +public class DeltaViewerSample { + + /** + * @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"); +// TraceJSON trace = new TraceJSON("traces/traceSample2.txt"); +// TraceJSON trace = new TraceJSON("traces/presenSample.txt"); +// 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/sampleCreate.trace"); +// TraceJSON trace = new TraceJSON("traces/sampleStatic.trace"); + + // Error display MagnetRON. +// 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(); + // �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); + +// HashSet marked = trace.getMarkedMethodSignatures(1255991806833871L, 1255991808597322L); +// HashSet marked = trace.getMarkedMethodSignatures(1699553004208835L, 1699553004739523L); +// System.out.println("===== Marked Methods ====="); +// for (String method: marked) { +// System.out.println(method); +// } +// HashSet unmarked = trace.getUnmarkedMethodSignatures(1255991806833871L, 1255991808597322L); +// HashSet unmarked = trace.getUnmarkedMethodSignatures(1699553004208835L, 1699553004739523L); +// System.out.println("===== Unmarked Methods ====="); +// for (String method: unmarked) { +// System.out.println(method); +// } + + // Change! + // setArray, setCollection(2��ڈȍ~�͕K�v�Ȃ�) , foreach(thread) +// ArrayList��add����ĂȂ� +// �t�B�[���h�ɑ������Ă��Ȃ� +// HashMap threads = trace.getAllThreads(); + for(ThreadInstance ti: threads.values()) { + ArrayList roots = ti.getRoot(); + for(MethodExecution root: roots) { + traverseMethodExecution(root); + } + } + + 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(); + } + +/* + * ���������� + * +===== Marked Methods ===== +void worstCase.O.passL(worstCase.L) +worstCase.L worstCase.I.getL() +worstCase.L worstCase.K.getL() +worstCase.M worstCase.L.getM() +worstCase.K worstCase.J.getK() +void worstCase.N.passI(worstCase.I) +void worstCase.P.setM(worstCase.M) +===== Unmarked Methods ===== +worstCase.F worstCase.C.getF() +worstCase.E worstCase.D.getE() +worstCase.A() +public worstCase.M() +worstCase.F() +void worstCase.A.m() +public static void worstCase.main.main(java.lang.String[]) +worstCase.G() +worstCase.H() +worstCase.I() +worstCase.B() +worstCase.C() +worstCase.D() +worstCase.E() +worstCase.N() +worstCase.O() +worstCase.P() +worstCase.F worstCase.E.getF() +worstCase.J() +worstCase.K() +worstCase.L() +worstCase.I worstCase.F.getI() +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() +worstCase.A() +void worstCase.P.setM(worstCase.M) +public worstCase.M() +worstCase.M worstCase.L.getM() +worstCase.L worstCase.I.getL() +worstCase.L worstCase.K.getL() +void worstCase.N.passI(worstCase.I) +void worstCase.A.m() +worstCase.F() +public static void worstCase.main.main(java.lang.String[]) +worstCase.G() +void worstCase.O.passL(worstCase.L) +worstCase.H() +worstCase.I() +worstCase.B() +worstCase.C() +worstCase.D() +worstCase.E() +worstCase.N() +worstCase.O() +worstCase.K worstCase.J.getK() +worstCase.F worstCase.E.getF() +worstCase.P() +worstCase.J() +worstCase.K() +worstCase.I worstCase.F.getI() +worstCase.I worstCase.H.getI() +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 +worstCase.A():1 +void worstCase.P.setM(worstCase.M):1 +public worstCase.M():1 +worstCase.M worstCase.L.getM():1 +worstCase.L worstCase.I.getL():1 +worstCase.L worstCase.K.getL():1 +void worstCase.N.passI(worstCase.I):1 +void worstCase.A.m():1 +worstCase.F():1 +public static void worstCase.main.main(java.lang.String[]):1 +worstCase.G():1 +void worstCase.O.passL(worstCase.L):1 +worstCase.H():1 +worstCase.I():1 +worstCase.B():1 +worstCase.C():1 +worstCase.D():1 +worstCase.E():1 +worstCase.N():1 +worstCase.O():1 +worstCase.K worstCase.J.getK():1 +worstCase.F worstCase.E.getF():1 +worstCase.P():1 +worstCase.J():1 +worstCase.K():1 +worstCase.I worstCase.F.getI():1 +worstCase.I worstCase.H.getI():1 +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()); +// return false; +// } +// @Override +// public boolean postVisitStatement(Statement statement) { +// System.out.println("post:" + statement.getClass().getName() + ":" + statement.getTimeStamp()); +// return false; +// } +// }); +/* + * ���������� + * +===== All Statements Forward ===== +pre:org.ntlab.trace.BlockEnter:1699552992988213 +post:org.ntlab.trace.BlockEnter:1699552992988213 +pre:org.ntlab.trace.MethodInvocation:1699552993730471 +pre:org.ntlab.trace.MethodInvocation:1699552994339441 +pre:org.ntlab.trace.MethodInvocation:1699552994979793 +pre:org.ntlab.trace.MethodInvocation:1699552995575363 +pre:org.ntlab.trace.MethodInvocation:1699552996163881 +pre:org.ntlab.trace.MethodInvocation:1699552996774613 +pre:org.ntlab.trace.MethodInvocation:1699552997363836 +pre:org.ntlab.trace.MethodInvocation:1699552997949532 +pre:org.ntlab.trace.MethodInvocation:1699552998548628 +pre:org.ntlab.trace.MethodInvocation:1699552999050402 +pre:org.ntlab.trace.MethodInvocation:1699552999466490 +pre:org.ntlab.trace.MethodInvocation:1699552999875526 +pre:org.ntlab.trace.MethodInvocation:1699553000173135 +post:org.ntlab.trace.MethodInvocation:1699553000173135 +pre:org.ntlab.trace.FieldUpdate:1699553000225322 +post:org.ntlab.trace.FieldUpdate:1699553000225322 +post:org.ntlab.trace.MethodInvocation:1699552999875526 +pre:org.ntlab.trace.FieldUpdate:1699553000259878 +post:org.ntlab.trace.FieldUpdate:1699553000259878 +post:org.ntlab.trace.MethodInvocation:1699552999466490 +pre:org.ntlab.trace.FieldUpdate:1699553000290908 +post:org.ntlab.trace.FieldUpdate:1699553000290908 +post:org.ntlab.trace.MethodInvocation:1699552999050402 +pre:org.ntlab.trace.FieldUpdate:1699553000331107 +post:org.ntlab.trace.FieldUpdate:1699553000331107 +post:org.ntlab.trace.MethodInvocation:1699552998548628 +pre:org.ntlab.trace.FieldUpdate:1699553000376947 +post:org.ntlab.trace.FieldUpdate:1699553000376947 +post:org.ntlab.trace.MethodInvocation:1699552997949532 +pre:org.ntlab.trace.FieldUpdate:1699553000422435 +post:org.ntlab.trace.FieldUpdate:1699553000422435 +post:org.ntlab.trace.MethodInvocation:1699552997363836 +pre:org.ntlab.trace.FieldUpdate:1699553000463691 +post:org.ntlab.trace.FieldUpdate:1699553000463691 +post:org.ntlab.trace.MethodInvocation:1699552996774613 +pre:org.ntlab.trace.FieldUpdate:1699553000508121 +post:org.ntlab.trace.FieldUpdate:1699553000508121 +post:org.ntlab.trace.MethodInvocation:1699552996163881 +pre:org.ntlab.trace.FieldUpdate:1699553000551845 +post:org.ntlab.trace.FieldUpdate:1699553000551845 +post:org.ntlab.trace.MethodInvocation:1699552995575363 +pre:org.ntlab.trace.FieldUpdate:1699553000596627 +post:org.ntlab.trace.FieldUpdate:1699553000596627 +post:org.ntlab.trace.MethodInvocation:1699552994979793 +pre:org.ntlab.trace.FieldUpdate:1699553000640352 +post:org.ntlab.trace.FieldUpdate:1699553000640352 +post:org.ntlab.trace.MethodInvocation:1699552994339441 +pre:org.ntlab.trace.FieldUpdate:1699553000682666 +post:org.ntlab.trace.FieldUpdate:1699553000682666 +pre:org.ntlab.trace.MethodInvocation:1699553001472175 +pre:org.ntlab.trace.MethodInvocation:1699553002201034 +pre:org.ntlab.trace.MethodInvocation:1699553003026510 +post:org.ntlab.trace.MethodInvocation:1699553003026510 +pre:org.ntlab.trace.FieldUpdate:1699553003101618 +post:org.ntlab.trace.FieldUpdate:1699553003101618 +post:org.ntlab.trace.MethodInvocation:1699553002201034 +pre:org.ntlab.trace.FieldUpdate:1699553003149926 +post:org.ntlab.trace.FieldUpdate:1699553003149926 +post:org.ntlab.trace.MethodInvocation:1699553001472175 +pre:org.ntlab.trace.FieldUpdate:1699553003190477 +post:org.ntlab.trace.FieldUpdate:1699553003190477 +post:org.ntlab.trace.MethodInvocation:1699552993730471 +pre:org.ntlab.trace.MethodInvocation:1699553003253243 +pre:org.ntlab.trace.BlockEnter:1699553003273695 +post:org.ntlab.trace.BlockEnter:1699553003273695 +pre:org.ntlab.trace.FieldAccess:1699553003299083 +post:org.ntlab.trace.FieldAccess:1699553003299083 +pre:org.ntlab.trace.FieldAccess:1699553003355502 +post:org.ntlab.trace.FieldAccess:1699553003355502 +pre:org.ntlab.trace.MethodInvocation:1699553003386885 +pre:org.ntlab.trace.BlockEnter:1699553003400637 +post:org.ntlab.trace.BlockEnter:1699553003400637 +pre:org.ntlab.trace.FieldAccess:1699553003436956 +post:org.ntlab.trace.FieldAccess:1699553003436956 +pre:org.ntlab.trace.MethodInvocation:1699553003482444 +pre:org.ntlab.trace.BlockEnter:1699553003500427 +post:org.ntlab.trace.BlockEnter:1699553003500427 +pre:org.ntlab.trace.FieldAccess:1699553003526169 +post:org.ntlab.trace.FieldAccess:1699553003526169 +pre:org.ntlab.trace.MethodInvocation:1699553003556141 +pre:org.ntlab.trace.BlockEnter:1699553003570951 +post:org.ntlab.trace.BlockEnter:1699553003570951 +pre:org.ntlab.trace.FieldAccess:1699553003599513 +post:org.ntlab.trace.FieldAccess:1699553003599513 +post:org.ntlab.trace.MethodInvocation:1699553003556141 +pre:org.ntlab.trace.MethodInvocation:1699553003668273 +pre:org.ntlab.trace.BlockEnter:1699553003688020 +post:org.ntlab.trace.BlockEnter:1699553003688020 +pre:org.ntlab.trace.FieldAccess:1699553003715876 +post:org.ntlab.trace.FieldAccess:1699553003715876 +post:org.ntlab.trace.MethodInvocation:1699553003668273 +post:org.ntlab.trace.MethodInvocation:1699553003482444 +pre:org.ntlab.trace.MethodInvocation:1699553003805088 +pre:org.ntlab.trace.BlockEnter:1699553003818135 +post:org.ntlab.trace.BlockEnter:1699553003818135 +pre:org.ntlab.trace.FieldAccess:1699553003846345 +post:org.ntlab.trace.FieldAccess:1699553003846345 +pre:org.ntlab.trace.MethodInvocation:1699553003896769 +pre:org.ntlab.trace.BlockEnter:1699553003912989 +post:org.ntlab.trace.BlockEnter:1699553003912989 +pre:org.ntlab.trace.FieldAccess:1699553003944020 +post:org.ntlab.trace.FieldAccess:1699553003944020 +post:org.ntlab.trace.MethodInvocation:1699553003896769 +pre:org.ntlab.trace.MethodInvocation:1699553004012075 +pre:org.ntlab.trace.BlockEnter:1699553004029706 +post:org.ntlab.trace.BlockEnter:1699553004029706 +pre:org.ntlab.trace.FieldAccess:1699553004082951 +post:org.ntlab.trace.FieldAccess:1699553004082951 +post:org.ntlab.trace.MethodInvocation:1699553004012075 +post:org.ntlab.trace.MethodInvocation:1699553003805088 +post:org.ntlab.trace.MethodInvocation:1699553003386885 +pre:org.ntlab.trace.MethodInvocation:1699553004208835 +pre:org.ntlab.trace.BlockEnter:1699553004228229 +post:org.ntlab.trace.BlockEnter:1699553004228229 +pre:org.ntlab.trace.FieldAccess:1699553004257849 +post:org.ntlab.trace.FieldAccess:1699553004257849 +pre:org.ntlab.trace.MethodInvocation:1699553004302631 +pre:org.ntlab.trace.BlockEnter:1699553004326962 +post:org.ntlab.trace.BlockEnter:1699553004326962 +pre:org.ntlab.trace.FieldAccess:1699553004373507 +post:org.ntlab.trace.FieldAccess:1699553004373507 +pre:org.ntlab.trace.MethodInvocation:1699553004418995 +pre:org.ntlab.trace.BlockEnter:1699553004434510 +post:org.ntlab.trace.BlockEnter:1699553004434510 +pre:org.ntlab.trace.FieldAccess:1699553004461661 +post:org.ntlab.trace.FieldAccess:1699553004461661 +post:org.ntlab.trace.MethodInvocation:1699553004418995 +pre:org.ntlab.trace.MethodInvocation:1699553004515964 +pre:org.ntlab.trace.BlockEnter:1699553004526543 +post:org.ntlab.trace.BlockEnter:1699553004526543 +pre:org.ntlab.trace.FieldAccess:1699553004546994 +post:org.ntlab.trace.FieldAccess:1699553004546994 +post:org.ntlab.trace.MethodInvocation:1699553004515964 +post:org.ntlab.trace.MethodInvocation:1699553004302631 +pre:org.ntlab.trace.MethodInvocation:1699553004606587 +pre:org.ntlab.trace.BlockEnter:1699553004615402 +post:org.ntlab.trace.BlockEnter:1699553004615402 +pre:org.ntlab.trace.FieldAccess:1699553004629507 +post:org.ntlab.trace.FieldAccess:1699553004629507 +pre:org.ntlab.trace.MethodInvocation:1699553004648195 +pre:org.ntlab.trace.BlockEnter:1699553004655953 +post:org.ntlab.trace.BlockEnter:1699553004655953 +pre:org.ntlab.trace.FieldAccess:1699553004670763 +post:org.ntlab.trace.FieldAccess:1699553004670763 +post:org.ntlab.trace.MethodInvocation:1699553004648195 +pre:org.ntlab.trace.MethodInvocation:1699553004703556 +pre:org.ntlab.trace.BlockEnter:1699553004712019 +post:org.ntlab.trace.BlockEnter:1699553004712019 +pre:org.ntlab.trace.FieldUpdate:1699553004728240 +post:org.ntlab.trace.FieldUpdate:1699553004728240 +post:org.ntlab.trace.MethodInvocation:1699553004703556 +post:org.ntlab.trace.MethodInvocation:1699553004606587 +post:org.ntlab.trace.MethodInvocation:1699553004208835 +post:org.ntlab.trace.MethodInvocation:1699553003253243 + */ + + // Change! +// System.out.println("===== All Statements Backward ====="); +// TracePoint tp = 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; +// dex.extract(tp, dac); +// 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; +// } +// }); + } + + private static void traverseMethodExecution(MethodExecution m) { + System.out.println(m.getSignature()); + for(Statement ms :m.getStatements()) { + if(ms instanceof FieldAccess) { + System.out.println(((FieldAccess)ms).getFieldName()); + } + } + for(MethodExecution m2: m.getChildren()) { + traverseMethodExecution(m2); + } + } +/* + * ���������� + * +===== All Statements Backward ===== +post:org.ntlab.trace.MethodInvocation:1699553003253243 +post:org.ntlab.trace.MethodInvocation:1699553004208835 +post:org.ntlab.trace.MethodInvocation:1699553004606587 +post:org.ntlab.trace.MethodInvocation:1699553004703556 +post:org.ntlab.trace.FieldUpdate:1699553004728240 +pre:org.ntlab.trace.FieldUpdate:1699553004728240 +post:org.ntlab.trace.BlockEnter:1699553004712019 +pre:org.ntlab.trace.BlockEnter:1699553004712019 +pre:org.ntlab.trace.MethodInvocation:1699553004703556 +post:org.ntlab.trace.MethodInvocation:1699553004648195 +post:org.ntlab.trace.FieldAccess:1699553004670763 +pre:org.ntlab.trace.FieldAccess:1699553004670763 +post:org.ntlab.trace.BlockEnter:1699553004655953 +pre:org.ntlab.trace.BlockEnter:1699553004655953 +pre:org.ntlab.trace.MethodInvocation:1699553004648195 +post:org.ntlab.trace.FieldAccess:1699553004629507 +pre:org.ntlab.trace.FieldAccess:1699553004629507 +post:org.ntlab.trace.BlockEnter:1699553004615402 +pre:org.ntlab.trace.BlockEnter:1699553004615402 +pre:org.ntlab.trace.MethodInvocation:1699553004606587 +post:org.ntlab.trace.MethodInvocation:1699553004302631 +post:org.ntlab.trace.MethodInvocation:1699553004515964 +post:org.ntlab.trace.FieldAccess:1699553004546994 +pre:org.ntlab.trace.FieldAccess:1699553004546994 +post:org.ntlab.trace.BlockEnter:1699553004526543 +pre:org.ntlab.trace.BlockEnter:1699553004526543 +pre:org.ntlab.trace.MethodInvocation:1699553004515964 +post:org.ntlab.trace.MethodInvocation:1699553004418995 +post:org.ntlab.trace.FieldAccess:1699553004461661 +pre:org.ntlab.trace.FieldAccess:1699553004461661 +post:org.ntlab.trace.BlockEnter:1699553004434510 +pre:org.ntlab.trace.BlockEnter:1699553004434510 +pre:org.ntlab.trace.MethodInvocation:1699553004418995 +post:org.ntlab.trace.FieldAccess:1699553004373507 +pre:org.ntlab.trace.FieldAccess:1699553004373507 +post:org.ntlab.trace.BlockEnter:1699553004326962 +pre:org.ntlab.trace.BlockEnter:1699553004326962 +pre:org.ntlab.trace.MethodInvocation:1699553004302631 +post:org.ntlab.trace.FieldAccess:1699553004257849 +pre:org.ntlab.trace.FieldAccess:1699553004257849 +post:org.ntlab.trace.BlockEnter:1699553004228229 +pre:org.ntlab.trace.BlockEnter:1699553004228229 +pre:org.ntlab.trace.MethodInvocation:1699553004208835 +post:org.ntlab.trace.MethodInvocation:1699553003386885 +post:org.ntlab.trace.MethodInvocation:1699553003805088 +post:org.ntlab.trace.MethodInvocation:1699553004012075 +post:org.ntlab.trace.FieldAccess:1699553004082951 +pre:org.ntlab.trace.FieldAccess:1699553004082951 +post:org.ntlab.trace.BlockEnter:1699553004029706 +pre:org.ntlab.trace.BlockEnter:1699553004029706 +pre:org.ntlab.trace.MethodInvocation:1699553004012075 +post:org.ntlab.trace.MethodInvocation:1699553003896769 +post:org.ntlab.trace.FieldAccess:1699553003944020 +pre:org.ntlab.trace.FieldAccess:1699553003944020 +post:org.ntlab.trace.BlockEnter:1699553003912989 +pre:org.ntlab.trace.BlockEnter:1699553003912989 +pre:org.ntlab.trace.MethodInvocation:1699553003896769 +post:org.ntlab.trace.FieldAccess:1699553003846345 +pre:org.ntlab.trace.FieldAccess:1699553003846345 +post:org.ntlab.trace.BlockEnter:1699553003818135 +pre:org.ntlab.trace.BlockEnter:1699553003818135 +pre:org.ntlab.trace.MethodInvocation:1699553003805088 +post:org.ntlab.trace.MethodInvocation:1699553003482444 +post:org.ntlab.trace.MethodInvocation:1699553003668273 +post:org.ntlab.trace.FieldAccess:1699553003715876 +pre:org.ntlab.trace.FieldAccess:1699553003715876 +post:org.ntlab.trace.BlockEnter:1699553003688020 +pre:org.ntlab.trace.BlockEnter:1699553003688020 +pre:org.ntlab.trace.MethodInvocation:1699553003668273 +post:org.ntlab.trace.MethodInvocation:1699553003556141 +post:org.ntlab.trace.FieldAccess:1699553003599513 +pre:org.ntlab.trace.FieldAccess:1699553003599513 +post:org.ntlab.trace.BlockEnter:1699553003570951 +pre:org.ntlab.trace.BlockEnter:1699553003570951 +pre:org.ntlab.trace.MethodInvocation:1699553003556141 +post:org.ntlab.trace.FieldAccess:1699553003526169 +pre:org.ntlab.trace.FieldAccess:1699553003526169 +post:org.ntlab.trace.BlockEnter:1699553003500427 +pre:org.ntlab.trace.BlockEnter:1699553003500427 +pre:org.ntlab.trace.MethodInvocation:1699553003482444 +post:org.ntlab.trace.FieldAccess:1699553003436956 +pre:org.ntlab.trace.FieldAccess:1699553003436956 +post:org.ntlab.trace.BlockEnter:1699553003400637 +pre:org.ntlab.trace.BlockEnter:1699553003400637 +pre:org.ntlab.trace.MethodInvocation:1699553003386885 +post:org.ntlab.trace.FieldAccess:1699553003355502 +pre:org.ntlab.trace.FieldAccess:1699553003355502 +post:org.ntlab.trace.FieldAccess:1699553003299083 +pre:org.ntlab.trace.FieldAccess:1699553003299083 +post:org.ntlab.trace.BlockEnter:1699553003273695 +pre:org.ntlab.trace.BlockEnter:1699553003273695 +pre:org.ntlab.trace.MethodInvocation:1699553003253243 +post:org.ntlab.trace.MethodInvocation:1699552993730471 +post:org.ntlab.trace.FieldUpdate:1699553003190477 +pre:org.ntlab.trace.FieldUpdate:1699553003190477 +post:org.ntlab.trace.MethodInvocation:1699553001472175 +post:org.ntlab.trace.FieldUpdate:1699553003149926 +pre:org.ntlab.trace.FieldUpdate:1699553003149926 +post:org.ntlab.trace.MethodInvocation:1699553002201034 +post:org.ntlab.trace.FieldUpdate:1699553003101618 +pre:org.ntlab.trace.FieldUpdate:1699553003101618 +post:org.ntlab.trace.MethodInvocation:1699553003026510 +pre:org.ntlab.trace.MethodInvocation:1699553003026510 +pre:org.ntlab.trace.MethodInvocation:1699553002201034 +pre:org.ntlab.trace.MethodInvocation:1699553001472175 +post:org.ntlab.trace.FieldUpdate:1699553000682666 +pre:org.ntlab.trace.FieldUpdate:1699553000682666 +post:org.ntlab.trace.MethodInvocation:1699552994339441 +post:org.ntlab.trace.FieldUpdate:1699553000640352 +pre:org.ntlab.trace.FieldUpdate:1699553000640352 +post:org.ntlab.trace.MethodInvocation:1699552994979793 +post:org.ntlab.trace.FieldUpdate:1699553000596627 +pre:org.ntlab.trace.FieldUpdate:1699553000596627 +post:org.ntlab.trace.MethodInvocation:1699552995575363 +post:org.ntlab.trace.FieldUpdate:1699553000551845 +pre:org.ntlab.trace.FieldUpdate:1699553000551845 +post:org.ntlab.trace.MethodInvocation:1699552996163881 +post:org.ntlab.trace.FieldUpdate:1699553000508121 +pre:org.ntlab.trace.FieldUpdate:1699553000508121 +post:org.ntlab.trace.MethodInvocation:1699552996774613 +post:org.ntlab.trace.FieldUpdate:1699553000463691 +pre:org.ntlab.trace.FieldUpdate:1699553000463691 +post:org.ntlab.trace.MethodInvocation:1699552997363836 +post:org.ntlab.trace.FieldUpdate:1699553000422435 +pre:org.ntlab.trace.FieldUpdate:1699553000422435 +post:org.ntlab.trace.MethodInvocation:1699552997949532 +post:org.ntlab.trace.FieldUpdate:1699553000376947 +pre:org.ntlab.trace.FieldUpdate:1699553000376947 +post:org.ntlab.trace.MethodInvocation:1699552998548628 +post:org.ntlab.trace.FieldUpdate:1699553000331107 +pre:org.ntlab.trace.FieldUpdate:1699553000331107 +post:org.ntlab.trace.MethodInvocation:1699552999050402 +post:org.ntlab.trace.FieldUpdate:1699553000290908 +pre:org.ntlab.trace.FieldUpdate:1699553000290908 +post:org.ntlab.trace.MethodInvocation:1699552999466490 +post:org.ntlab.trace.FieldUpdate:1699553000259878 +pre:org.ntlab.trace.FieldUpdate:1699553000259878 +post:org.ntlab.trace.MethodInvocation:1699552999875526 +post:org.ntlab.trace.FieldUpdate:1699553000225322 +pre:org.ntlab.trace.FieldUpdate:1699553000225322 +post:org.ntlab.trace.MethodInvocation:1699553000173135 +pre:org.ntlab.trace.MethodInvocation:1699553000173135 +pre:org.ntlab.trace.MethodInvocation:1699552999875526 +pre:org.ntlab.trace.MethodInvocation:1699552999466490 +pre:org.ntlab.trace.MethodInvocation:1699552999050402 +pre:org.ntlab.trace.MethodInvocation:1699552998548628 +pre:org.ntlab.trace.MethodInvocation:1699552997949532 +pre:org.ntlab.trace.MethodInvocation:1699552997363836 +pre:org.ntlab.trace.MethodInvocation:1699552996774613 +pre:org.ntlab.trace.MethodInvocation:1699552996163881 +pre:org.ntlab.trace.MethodInvocation:1699552995575363 +pre:org.ntlab.trace.MethodInvocation:1699552994979793 +pre:org.ntlab.trace.MethodInvocation:1699552994339441 +pre:org.ntlab.trace.MethodInvocation:1699552993730471 +post:org.ntlab.trace.BlockEnter:1699552992988213 +pre:org.ntlab.trace.BlockEnter:1699552992988213 + */ +} diff --git a/src/org/ntlab/deltaViewer/Edge.java b/src/org/ntlab/deltaViewer/Edge.java index 547eeb2..bcc3c95 100644 --- a/src/org/ntlab/deltaViewer/Edge.java +++ b/src/org/ntlab/deltaViewer/Edge.java @@ -1,53 +1,54 @@ -package org.ntlab.deltaViewer; - -/** - * JGraphX Edge. - * - * @author Nitta Lab. - */ -public class Edge { - String label; - TypeName typeName; - Object cell; - - protected enum TypeName { - Reference, // object reference - Call // method call - } - - /** - * @param label No display label - * @param typeName - * @param cell - */ - public Edge(String label, TypeName typeName, Object cell) { - this.label = label; - this.typeName = typeName; - this.cell = cell; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public TypeName getTypeName() { - return typeName; - } - - public void setTypeName(TypeName typeName) { - this.typeName = typeName; - } - - public Object getCell() { - return cell; - } - - public void setCell(Object cell) { - this.cell = cell; - } - -} +package org.ntlab.deltaViewer; + +/** + * JGraphX Edge. + * + * @author Nitta Lab. + */ +public class Edge { + String label; + TypeName typeName; + Object cell; + + protected enum TypeName { + Reference, // object reference + Create, // create object reference + Call // method call + } + + /** + * @param label No display label + * @param typeName + * @param cell + */ + public Edge(String label, TypeName typeName, Object cell) { + this.label = label; + this.typeName = typeName; + this.cell = cell; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public TypeName getTypeName() { + return typeName; + } + + public void setTypeName(TypeName typeName) { + this.typeName = typeName; + } + + public Object getCell() { + return cell; + } + + public void setCell(Object cell) { + this.cell = cell; + } + +} diff --git a/src/org/ntlab/deltaViewer/JGraphTSample.java b/src/org/ntlab/deltaViewer/JGraphTSample.java index f61d6a5..d9df300 100644 --- a/src/org/ntlab/deltaViewer/JGraphTSample.java +++ b/src/org/ntlab/deltaViewer/JGraphTSample.java @@ -1,192 +1,192 @@ -/* - * (C) Copyright 2013-2018, by Barak Naveh and Contributors. - * - * JGraphT : a free Java graph-theory library - * - * See the CONTRIBUTORS.md file distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the - * GNU Lesser General Public License v2.1 or later - * which is available at - * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html. - * - * SPDX-License-Identifier: EPL-2.0 OR LGPL-2.1-or-later - */ -package org.ntlab.deltaViewer; - -import com.mxgraph.model.mxCell; -import com.mxgraph.swing.*; -import com.mxgraph.util.mxConstants; -import com.mxgraph.util.mxLine; -import com.mxgraph.util.mxPoint; -import com.mxgraph.view.mxGraph; - -import org.jgrapht.ext.*; -import org.jgrapht.graph.*; - -import javax.swing.*; -import java.awt.*; -import java.awt.geom.Ellipse2D; - -/** - * A demo applet that shows how to use JGraphX to visualize JGraphT graphs. Applet based on - * JGraphAdapterDemo. - * - */ -public class JGraphTSample extends JApplet { - private static final Dimension DEFAULT_SIZE = new Dimension(530, 320); - private JGraphXAdapter jgxAdapter; - - /** - * An alternative starting point for this demo, to also allow running this applet as an - * application. - * - * @param args Command line arguments. - */ - /** - * @param args - */ - public static void main(String[] args) - { - //Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. - JFrame frame = new JFrame("Branching graph"); - frame.setSize(500, 500); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - mxGraph mxgraph= new mxGraph(); - mxGraphComponent graphComponent= new mxGraphComponent(mxgraph); - - frame.add(graphComponent, BorderLayout.CENTER); - frame.setVisible(true); - - //No clue what this does but it is needed. - Object mxDefaultParent = mxgraph.getDefaultParent(); - - //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. - Object vertex=null; - Object A=null; - Object B=null; - Object C=null; - Object D=null; - Object E=null; - - Object Am=null; - Object Bm=null; - Object Dm=null; - Object Em=null; - - Object b=null; - Object c=null; - Object d=null; - Object e=null; - - Object AmE=null; - Object BmE=null; - Object DmE=null; - mxgraph.getModel().beginUpdate(); - try{ - double xCor=225; - double yCor=100.0; - double width=70; - double height=70; - - A=mxgraph.insertVertex(mxDefaultParent, "A", "A", xCor, yCor, width , height,"fillColor=blue"); //creates a blue vertex - B=mxgraph.insertVertex(mxDefaultParent, "B", "B", xCor-100, yCor+100, width, height,"fillColor=blue"); - C=mxgraph.insertVertex(mxDefaultParent, "C", "C", xCor-200, yCor+200, width , height,"fillColor=blue"); - D=mxgraph.insertVertex(mxDefaultParent, "D", "D", xCor+100, yCor+100, width , height,"fillColor=blue"); - E=mxgraph.insertVertex(mxDefaultParent, "E", "E", xCor+200 , yCor+200, width, height,"fillColor=blue"); - - Am=mxgraph.insertVertex(mxDefaultParent, "Am", "A.m()", getXForCell(mxgraph, "A")+10, yCor+40, width-15 , height-40,"fillColor=blue; alignVertical=middle"); //creates a blue vertex - Bm=mxgraph.insertVertex(mxDefaultParent, "Bm", "B.getC()", getXForCell(mxgraph, "B")+10, yCor+140, width-15, height-50,"fillColor=blue"); - Dm=mxgraph.insertVertex(mxDefaultParent, "Dm", "D.passB()", getXForCell(mxgraph, "D")+10, yCor+140, width-15 , height-50,"fillColor=blue"); - Em=mxgraph.insertVertex(mxDefaultParent, "Em", "E.setC()", getXForCell(mxgraph, "E")+10 , yCor+240, width-15, height-50,"fillColor=blue"); - - b = mxgraph.insertEdge(mxDefaultParent, "b", "b", A, B, "edgeStyle=elbowEdgeStyle;elbow=horizontal;" - + "exitX=0.5;exitY=1;exitPerimeter=1;entryX=-10;entryY=-10;entryPerimeter=1;"); - c = mxgraph.insertEdge(mxDefaultParent, "c", "c", B, C); - d = mxgraph.insertEdge(mxDefaultParent, "d", "d", A, D); - e = mxgraph.insertEdge(mxDefaultParent, "e", "e", D, E); - - AmE = mxgraph.insertEdge(mxDefaultParent, "AmE", "", Am, Bm); - BmE = mxgraph.insertEdge(mxDefaultParent, "BmE", "", Bm, Dm); - DmE = mxgraph.insertEdge(mxDefaultParent, "DmE", "", Dm, Em); - - final Graphics2D g = (Graphics2D)graphComponent.getGraphics(); -// mxGraphics2DCanvas canvas = new mxGraphics2DCanvas(g); -// canvas.paintPolyline(new mxPoint[] {new mxPoint(100,100),new mxPoint(500,500)}, true); - Runnable r = new Runnable() { - public void run() { - g.setColor(Color.GREEN); - Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0); - g.setStroke(dashed); - g.drawLine(0, 0, 500, 500); - } - }; - - if (!SwingUtilities.isEventDispatchThread()) { - SwingUtilities.invokeLater(r); - } else { - r.run(); - } - - - } - finally{ - mxgraph.getModel().endUpdate(); - } - - /*Given a cell, we can change it's style attributes, for example the color. NOTE that you have to call the graphComponent.refresh() function, otherwise you won't see the difference!*/ - mxgraph.setCellStyles(mxConstants.STYLE_FILLCOLOR, "white", new Object[]{A, B, C, D, E, Am, Bm, Dm, Em}); //changes the color to red - mxgraph.setCellStyles(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE, new Object[]{A, B, C, D, E}); - mxgraph.setCellStyles(mxConstants.STYLE_PERIMETER, mxConstants.PERIMETER_ELLIPSE, new Object[]{A, B, C, D, E}); - mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.SHAPE_CURVE, new Object[] {AmE, BmE, DmE, b, c, d, e}); - mxgraph.setCellStyleFlags(mxConstants.STYLE_DASHED, 1, true, new Object[] {AmE, BmE, DmE}); - // Adds animation to edge shape and makes "pipe" visible - ((mxCell)b).setAttribute("path", ".flow {" - + "stroke-dasharray: 8;" - + "animation: dash 0.5s linear;" - + "animation-iteration-count: infinite;" - + "}" - + "@keyframes dash {" - + "to {" - + "stroke-dashoffset: -16;" - + "}"); - - graphComponent.refresh(); - - } - - private static double getXForCell(mxGraph graph, String id) { - double res = -1; - graph.clearSelection(); - graph.selectAll(); - Object[] cells = graph.getSelectionCells(); - for (Object object : cells) { - mxCell cell = (mxCell) object; - if (id.equals(cell.getId())) { - res = cell.getGeometry().getX(); - } - } - graph.clearSelection(); - return res; - } - - class GPanel extends JPanel { - - @Override - public void paintComponent(Graphics g) { - super.paintComponent(g); - Graphics2D g2 = (Graphics2D)g; - int w = this.getWidth(); - int h = this.getHeight(); - for(int i = 0;i < 10;i++){ - Ellipse2D shape = new Ellipse2D.Double(0,0,w,h - i * (w / 10)); - g2.setPaint(new Color(0,0,255,25)); - g2.fill(shape); - } - } - } +/* + * (C) Copyright 2013-2018, by Barak Naveh and Contributors. + * + * JGraphT : a free Java graph-theory library + * + * See the CONTRIBUTORS.md file distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the + * GNU Lesser General Public License v2.1 or later + * which is available at + * http://www.gnu.org/licenses/old-licenses/lgpl-2.1-standalone.html. + * + * SPDX-License-Identifier: EPL-2.0 OR LGPL-2.1-or-later + */ +package org.ntlab.deltaViewer; + +import com.mxgraph.model.mxCell; +import com.mxgraph.swing.*; +import com.mxgraph.util.mxConstants; +import com.mxgraph.util.mxLine; +import com.mxgraph.util.mxPoint; +import com.mxgraph.view.mxGraph; + +import org.jgrapht.ext.*; +import org.jgrapht.graph.*; + +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Ellipse2D; + +/** + * A demo applet that shows how to use JGraphX to visualize JGraphT graphs. Applet based on + * JGraphAdapterDemo. + * + */ +public class JGraphTSample extends JApplet { + private static final Dimension DEFAULT_SIZE = new Dimension(530, 320); + private JGraphXAdapter jgxAdapter; + + /** + * An alternative starting point for this demo, to also allow running this applet as an + * application. + * + * @param args Command line arguments. + */ + /** + * @param args + */ + public static void main(String[] args) + { + //Build a frame, create a graph, and add the graph to the frame so you can actually see the graph. + JFrame frame = new JFrame("Branching graph"); + frame.setSize(500, 500); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + mxGraph mxgraph= new mxGraph(); + mxGraphComponent graphComponent= new mxGraphComponent(mxgraph); + + frame.add(graphComponent, BorderLayout.CENTER); + frame.setVisible(true); + + //No clue what this does but it is needed. + Object mxDefaultParent = mxgraph.getDefaultParent(); + + //Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. + Object vertex=null; + Object A=null; + Object B=null; + Object C=null; + Object D=null; + Object E=null; + + Object Am=null; + Object Bm=null; + Object Dm=null; + Object Em=null; + + Object b=null; + Object c=null; + Object d=null; + Object e=null; + + Object AmE=null; + Object BmE=null; + Object DmE=null; + mxgraph.getModel().beginUpdate(); + try{ + double xCor=225; + double yCor=100.0; + double width=70; + double height=70; + + A=mxgraph.insertVertex(mxDefaultParent, "A", "A", xCor, yCor, width , height,"fillColor=blue"); //creates a blue vertex + B=mxgraph.insertVertex(mxDefaultParent, "B", "B", xCor-100, yCor+100, width, height,"fillColor=blue"); + C=mxgraph.insertVertex(mxDefaultParent, "C", "C", xCor-200, yCor+200, width , height,"fillColor=blue"); + D=mxgraph.insertVertex(mxDefaultParent, "D", "D", xCor+100, yCor+100, width , height,"fillColor=blue"); + E=mxgraph.insertVertex(mxDefaultParent, "E", "E", xCor+200 , yCor+200, width, height,"fillColor=blue"); + + Am=mxgraph.insertVertex(mxDefaultParent, "Am", "A.m()", getXForCell(mxgraph, "A")+10, yCor+40, width-15 , height-40,"fillColor=blue; alignVertical=middle"); //creates a blue vertex + Bm=mxgraph.insertVertex(mxDefaultParent, "Bm", "B.getC()", getXForCell(mxgraph, "B")+10, yCor+140, width-15, height-50,"fillColor=blue"); + Dm=mxgraph.insertVertex(mxDefaultParent, "Dm", "D.passB()", getXForCell(mxgraph, "D")+10, yCor+140, width-15 , height-50,"fillColor=blue"); + Em=mxgraph.insertVertex(mxDefaultParent, "Em", "E.setC()", getXForCell(mxgraph, "E")+10 , yCor+240, width-15, height-50,"fillColor=blue"); + + b = mxgraph.insertEdge(mxDefaultParent, "b", "b", A, B, "edgeStyle=elbowEdgeStyle;elbow=horizontal;" + + "exitX=0.5;exitY=1;exitPerimeter=1;entryX=-10;entryY=-10;entryPerimeter=1;"); + c = mxgraph.insertEdge(mxDefaultParent, "c", "c", B, C); + d = mxgraph.insertEdge(mxDefaultParent, "d", "d", A, D); + e = mxgraph.insertEdge(mxDefaultParent, "e", "e", D, E); + + AmE = mxgraph.insertEdge(mxDefaultParent, "AmE", "", Am, Bm); + BmE = mxgraph.insertEdge(mxDefaultParent, "BmE", "", Bm, Dm); + DmE = mxgraph.insertEdge(mxDefaultParent, "DmE", "", Dm, Em); + + final Graphics2D g = (Graphics2D)graphComponent.getGraphics(); +// mxGraphics2DCanvas canvas = new mxGraphics2DCanvas(g); +// canvas.paintPolyline(new mxPoint[] {new mxPoint(100,100),new mxPoint(500,500)}, true); + Runnable r = new Runnable() { + public void run() { + g.setColor(Color.GREEN); + Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0); + g.setStroke(dashed); + g.drawLine(0, 0, 500, 500); + } + }; + + if (!SwingUtilities.isEventDispatchThread()) { + SwingUtilities.invokeLater(r); + } else { + r.run(); + } + + + } + finally{ + mxgraph.getModel().endUpdate(); + } + + /*Given a cell, we can change it's style attributes, for example the color. NOTE that you have to call the graphComponent.refresh() function, otherwise you won't see the difference!*/ + mxgraph.setCellStyles(mxConstants.STYLE_FILLCOLOR, "white", new Object[]{A, B, C, D, E, Am, Bm, Dm, Em}); //changes the color to red + mxgraph.setCellStyles(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE, new Object[]{A, B, C, D, E}); + mxgraph.setCellStyles(mxConstants.STYLE_PERIMETER, mxConstants.PERIMETER_ELLIPSE, new Object[]{A, B, C, D, E}); + mxgraph.setCellStyles(mxConstants.STYLE_EDGE, mxConstants.SHAPE_CURVE, new Object[] {AmE, BmE, DmE, b, c, d, e}); + mxgraph.setCellStyleFlags(mxConstants.STYLE_DASHED, 1, true, new Object[] {AmE, BmE, DmE}); + // Adds animation to edge shape and makes "pipe" visible + ((mxCell)b).setAttribute("path", ".flow {" + + "stroke-dasharray: 8;" + + "animation: dash 0.5s linear;" + + "animation-iteration-count: infinite;" + + "}" + + "@keyframes dash {" + + "to {" + + "stroke-dashoffset: -16;" + + "}"); + + graphComponent.refresh(); + + } + + private static double getXForCell(mxGraph graph, String id) { + double res = -1; + graph.clearSelection(); + graph.selectAll(); + Object[] cells = graph.getSelectionCells(); + for (Object object : cells) { + mxCell cell = (mxCell) object; + if (id.equals(cell.getId())) { + res = cell.getGeometry().getX(); + } + } + graph.clearSelection(); + return res; + } + + class GPanel extends JPanel { + + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2 = (Graphics2D)g; + int w = this.getWidth(); + int h = this.getHeight(); + for(int i = 0;i < 10;i++){ + Ellipse2D shape = new Ellipse2D.Double(0,0,w,h - i * (w / 10)); + g2.setPaint(new Color(0,0,255,25)); + g2.fill(shape); + } + } + } } \ No newline at end of file diff --git a/src/org/ntlab/deltaViewer/MethodExecutionVertex.java b/src/org/ntlab/deltaViewer/MethodExecutionVertex.java new file mode 100644 index 0000000..7d30f84 --- /dev/null +++ b/src/org/ntlab/deltaViewer/MethodExecutionVertex.java @@ -0,0 +1,40 @@ +package org.ntlab.deltaViewer; + +import java.util.ArrayList; +import java.util.List; + +/** + * Method execution vertex. + * + * @author Nitta Lab. + */ +public class MethodExecutionVertex extends Vertex { + protected List locals = new ArrayList<>(); // Return value + protected List arguments = new ArrayList<>(); + + + public MethodExecutionVertex(String label, Object cell) { + super(label, cell); + } + + public MethodExecutionVertex(String label, Object cell, double x, double y, double width, double height) { + super(label, cell, x, y, width, height); + } + + public List getLocals() { + return locals; + } + + public void setLocals(List locals) { + this.locals = locals; + } + + public List getArguments() { + return arguments; + } + + public void setArguments(List arguments) { + this.arguments = arguments; + } + +} diff --git a/src/org/ntlab/deltaViewer/ObjectVertex.java b/src/org/ntlab/deltaViewer/ObjectVertex.java new file mode 100644 index 0000000..d161d3b --- /dev/null +++ b/src/org/ntlab/deltaViewer/ObjectVertex.java @@ -0,0 +1,39 @@ +package org.ntlab.deltaViewer; + +import java.util.ArrayList; +import java.util.List; + +import com.mxgraph.model.mxICell; + +/** + * Object vertex. + * + * @author Nitta Lab. + */ +public class ObjectVertex extends Vertex { + protected List vertexMethodExecutions = new ArrayList<>(); + + public ObjectVertex(String label, Object cell) { + super(label, cell); + } + + public ObjectVertex(String label, Object cell, double initialX, double initialY) { + super(label, cell, initialX, initialY); + } + + public ObjectVertex(String label, Object cell, double x, double y, double width, double height) { + super(label, cell, x, y, width, height); + } + + public List getVertexMethodExecutions() { + return vertexMethodExecutions; + } + + public void setVertexMethodExecutions(List vertexMethodExecutions) { + this.vertexMethodExecutions = vertexMethodExecutions; + } + + public void addMethodExecution(MethodExecutionVertex vertexMethodExecution) { + this.vertexMethodExecutions.add(vertexMethodExecution); + } +} diff --git a/src/org/ntlab/deltaViewer/Vertex.java b/src/org/ntlab/deltaViewer/Vertex.java index 14fd533..268d95f 100644 --- a/src/org/ntlab/deltaViewer/Vertex.java +++ b/src/org/ntlab/deltaViewer/Vertex.java @@ -1,109 +1,109 @@ -package org.ntlab.deltaViewer; - -import com.mxgraph.model.mxICell; - -/** - * JGraphX Vertex. - * - * @author Nitta Lab. - */ -public class Vertex { - String label; - Object cell; - double initialX; - double initialY; - double x; - double y; - double width; - double height; - - public Vertex(String label, Object cell) { - this.label = label; - this.cell = cell; - } - - public Vertex(String label, Object cell, double initialX, double initialY) { - this.label = label; - this.cell = cell; - this.initialX = initialX; - this.initialY = initialY; - } - - public Vertex(String label, Object cell, double x, double y, double width, double height) { - this.label = label; - this.cell = cell; - this.x = x; - this.y = y; - this.width = width; - this.height = height; - ((mxICell)cell).getGeometry().setX(x); - ((mxICell)cell).getGeometry().setY(y); - ((mxICell)cell).getGeometry().setWidth(width); - ((mxICell)cell).getGeometry().setHeight(height); - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public Object getCell() { - return cell; - } - - public void setCell(Object cell) { - this.cell = cell; - } - - public double getX() { - return x; - } - - public void setX(double x) { - this.x = x; - ((mxICell)cell).getGeometry().setX(x); - } - - public double getY() { - return y; - } - - public void setY(double y) { - this.y = y; - ((mxICell)cell).getGeometry().setY(y); - } - - public double getWidth() { - return width; - } - - public void setWidth(double width) { - this.width = width; - ((mxICell)cell).getGeometry().setWidth(width); - } - - public double getHeight() { - return height; - } - - public void setHeight(double height) { - this.height = height; - ((mxICell)cell).getGeometry().setHeight(height); - } - - public double getInitialX() { - return initialX; - } - - public double getInitialY() { - return initialY; - } - - public void resetCellPosition() { - ((mxICell)cell).getGeometry().setX(initialX); - ((mxICell)cell).getGeometry().setY(initialY); - } -} +package org.ntlab.deltaViewer; + +import com.mxgraph.model.mxICell; + +/** + * JGraphX Vertex. + * + * @author Nitta Lab. + */ +public class Vertex { + String label; + Object cell; + double initialX; + double initialY; + double x; + double y; + double width; + double height; + + public Vertex(String label, Object cell) { + this.label = label; + this.cell = cell; + } + + public Vertex(String label, Object cell, double initialX, double initialY) { + this.label = label; + this.cell = cell; + this.initialX = initialX; + this.initialY = initialY; + } + + public Vertex(String label, Object cell, double x, double y, double width, double height) { + this.label = label; + this.cell = cell; + this.x = x; + this.y = y; + this.width = width; + this.height = height; + ((mxICell)cell).getGeometry().setX(x); + ((mxICell)cell).getGeometry().setY(y); + ((mxICell)cell).getGeometry().setWidth(width); + ((mxICell)cell).getGeometry().setHeight(height); + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public Object getCell() { + return cell; + } + + public void setCell(Object cell) { + this.cell = cell; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + ((mxICell)cell).getGeometry().setX(x); + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + ((mxICell)cell).getGeometry().setY(y); + } + + public double getWidth() { + return width; + } + + public void setWidth(double width) { + this.width = width; + ((mxICell)cell).getGeometry().setWidth(width); + } + + public double getHeight() { + return height; + } + + public void setHeight(double height) { + this.height = height; + ((mxICell)cell).getGeometry().setHeight(height); + } + + public double getInitialX() { + return initialX; + } + + public double getInitialY() { + return initialY; + } + + public void resetCellPosition() { + ((mxICell)cell).getGeometry().setX(initialX); + ((mxICell)cell).getGeometry().setY(initialY); + } +} diff --git a/src/org/ntlab/deltaViewer/VertexMethodExecution.java b/src/org/ntlab/deltaViewer/VertexMethodExecution.java deleted file mode 100644 index eaa5db0..0000000 --- a/src/org/ntlab/deltaViewer/VertexMethodExecution.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.ntlab.deltaViewer; - -import java.util.ArrayList; -import java.util.List; - -/** - * Method execution vertex. - * - * @author Nitta Lab. - */ -public class VertexMethodExecution extends Vertex { - protected List locals = new ArrayList<>(); - protected List arguments = new ArrayList<>(); - - - public VertexMethodExecution(String label, Object cell) { - super(label, cell); - } - - public VertexMethodExecution(String label, Object cell, double x, double y, double width, double height) { - super(label, cell, x, y, width, height); - } - - public List getLocals() { - return locals; - } - - public void setLocals(List locals) { - this.locals = locals; - } - - public List getArguments() { - return arguments; - } - - public void setArguments(List arguments) { - this.arguments = arguments; - } - -} diff --git a/src/org/ntlab/deltaViewer/VertexObject.java b/src/org/ntlab/deltaViewer/VertexObject.java deleted file mode 100644 index 3e043eb..0000000 --- a/src/org/ntlab/deltaViewer/VertexObject.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.ntlab.deltaViewer; - -import java.util.ArrayList; -import java.util.List; - -import com.mxgraph.model.mxICell; - -/** - * Object vertex. - * - * @author Nitta Lab. - */ -public class VertexObject extends Vertex { - protected List methodExecutions = new ArrayList<>(); - - public VertexObject(String label, Object cell) { - super(label, cell); - } - - public VertexObject(String label, Object cell, double initialX, double initialY) { - super(label, cell, initialX, initialY); - } - - public VertexObject(String label, Object cell, double x, double y, double width, double height) { - super(label, cell, x, y, width, height); - } - - public List getMethodExecutions() { - return methodExecutions; - } - - public void setMethodExecutions(List methodExecutions) { - this.methodExecutions = methodExecutions; - } - - public void addMethodExecution(VertexMethodExecution methodExecution) { - this.methodExecutions.add(methodExecution); - } -} diff --git a/src/org/ntlab/trace/DeltaViewerSample.java b/src/org/ntlab/trace/DeltaViewerSample.java deleted file mode 100644 index 46eb159..0000000 --- a/src/org/ntlab/trace/DeltaViewerSample.java +++ /dev/null @@ -1,625 +0,0 @@ -package org.ntlab.trace; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; - -import org.ntlab.deltaExtractor.Alias; -import org.ntlab.deltaExtractor.DeltaExtractorJSON; -import org.ntlab.deltaExtractor.ExtractedStructure; -import org.ntlab.deltaViewer.DeltaAliasCollector; -import org.ntlab.deltaViewer.DeltaViewer; - -/** - * Delta viewer sample for MagnetRON. - * - * @author Nitta Lab. - */ -public class DeltaViewerSample { - - /** - * @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"); -// TraceJSON trace = new TraceJSON("traces/traceSample2.txt"); -// TraceJSON trace = new TraceJSON("traces/presenSample.txt"); - TraceJSON trace = new TraceJSON("traces/_worstCase.txt"); - - // Error display MagnetRON. -// 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(); - TracePoint tp = thread.getRoot().get(thread.getRoot().size() - 1).getExitPoint(); - DeltaAliasCollector dac = new DeltaAliasCollector(); -// 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); - -// HashSet marked = trace.getMarkedMethodSignatures(1255991806833871L, 1255991808597322L); -// HashSet marked = trace.getMarkedMethodSignatures(1699553004208835L, 1699553004739523L); -// System.out.println("===== Marked Methods ====="); -// for (String method: marked) { -// System.out.println(method); -// } -// HashSet unmarked = trace.getUnmarkedMethodSignatures(1255991806833871L, 1255991808597322L); -// HashSet unmarked = trace.getUnmarkedMethodSignatures(1699553004208835L, 1699553004739523L); -// System.out.println("===== Unmarked Methods ====="); -// for (String method: unmarked) { -// System.out.println(method); -// } - - // Change! -// HashMap threads = trace.getAllThreads(); - for(ThreadInstance ti: threads.values()) { - ArrayList roots = ti.getRoot(); - for(MethodExecution root: roots) { - traverseMethodExecution(root); - } - } - - DeltaViewer dv = new DeltaViewer(e, dac); - List aliasList = new ArrayList<>(dac.getAliasList()); -// dv.setCoordinatorPoint(1200, 100); - dv.init(); - - for(int i = 0; i <= aliasList.size(); i++) { - dv.stepToAnimation(i); - dv.display(); - } - -/* - * ���������� - * -===== Marked Methods ===== -void worstCase.O.passL(worstCase.L) -worstCase.L worstCase.I.getL() -worstCase.L worstCase.K.getL() -worstCase.M worstCase.L.getM() -worstCase.K worstCase.J.getK() -void worstCase.N.passI(worstCase.I) -void worstCase.P.setM(worstCase.M) -===== Unmarked Methods ===== -worstCase.F worstCase.C.getF() -worstCase.E worstCase.D.getE() -worstCase.A() -public worstCase.M() -worstCase.F() -void worstCase.A.m() -public static void worstCase.main.main(java.lang.String[]) -worstCase.G() -worstCase.H() -worstCase.I() -worstCase.B() -worstCase.C() -worstCase.D() -worstCase.E() -worstCase.N() -worstCase.O() -worstCase.P() -worstCase.F worstCase.E.getF() -worstCase.J() -worstCase.K() -worstCase.L() -worstCase.I worstCase.F.getI() -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() -worstCase.A() -void worstCase.P.setM(worstCase.M) -public worstCase.M() -worstCase.M worstCase.L.getM() -worstCase.L worstCase.I.getL() -worstCase.L worstCase.K.getL() -void worstCase.N.passI(worstCase.I) -void worstCase.A.m() -worstCase.F() -public static void worstCase.main.main(java.lang.String[]) -worstCase.G() -void worstCase.O.passL(worstCase.L) -worstCase.H() -worstCase.I() -worstCase.B() -worstCase.C() -worstCase.D() -worstCase.E() -worstCase.N() -worstCase.O() -worstCase.K worstCase.J.getK() -worstCase.F worstCase.E.getF() -worstCase.P() -worstCase.J() -worstCase.K() -worstCase.I worstCase.F.getI() -worstCase.I worstCase.H.getI() -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 -worstCase.A():1 -void worstCase.P.setM(worstCase.M):1 -public worstCase.M():1 -worstCase.M worstCase.L.getM():1 -worstCase.L worstCase.I.getL():1 -worstCase.L worstCase.K.getL():1 -void worstCase.N.passI(worstCase.I):1 -void worstCase.A.m():1 -worstCase.F():1 -public static void worstCase.main.main(java.lang.String[]):1 -worstCase.G():1 -void worstCase.O.passL(worstCase.L):1 -worstCase.H():1 -worstCase.I():1 -worstCase.B():1 -worstCase.C():1 -worstCase.D():1 -worstCase.E():1 -worstCase.N():1 -worstCase.O():1 -worstCase.K worstCase.J.getK():1 -worstCase.F worstCase.E.getF():1 -worstCase.P():1 -worstCase.J():1 -worstCase.K():1 -worstCase.I worstCase.F.getI():1 -worstCase.I worstCase.H.getI():1 -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()); -// return false; -// } -// @Override -// public boolean postVisitStatement(Statement statement) { -// System.out.println("post:" + statement.getClass().getName() + ":" + statement.getTimeStamp()); -// return false; -// } -// }); -/* - * ���������� - * -===== All Statements Forward ===== -pre:org.ntlab.trace.BlockEnter:1699552992988213 -post:org.ntlab.trace.BlockEnter:1699552992988213 -pre:org.ntlab.trace.MethodInvocation:1699552993730471 -pre:org.ntlab.trace.MethodInvocation:1699552994339441 -pre:org.ntlab.trace.MethodInvocation:1699552994979793 -pre:org.ntlab.trace.MethodInvocation:1699552995575363 -pre:org.ntlab.trace.MethodInvocation:1699552996163881 -pre:org.ntlab.trace.MethodInvocation:1699552996774613 -pre:org.ntlab.trace.MethodInvocation:1699552997363836 -pre:org.ntlab.trace.MethodInvocation:1699552997949532 -pre:org.ntlab.trace.MethodInvocation:1699552998548628 -pre:org.ntlab.trace.MethodInvocation:1699552999050402 -pre:org.ntlab.trace.MethodInvocation:1699552999466490 -pre:org.ntlab.trace.MethodInvocation:1699552999875526 -pre:org.ntlab.trace.MethodInvocation:1699553000173135 -post:org.ntlab.trace.MethodInvocation:1699553000173135 -pre:org.ntlab.trace.FieldUpdate:1699553000225322 -post:org.ntlab.trace.FieldUpdate:1699553000225322 -post:org.ntlab.trace.MethodInvocation:1699552999875526 -pre:org.ntlab.trace.FieldUpdate:1699553000259878 -post:org.ntlab.trace.FieldUpdate:1699553000259878 -post:org.ntlab.trace.MethodInvocation:1699552999466490 -pre:org.ntlab.trace.FieldUpdate:1699553000290908 -post:org.ntlab.trace.FieldUpdate:1699553000290908 -post:org.ntlab.trace.MethodInvocation:1699552999050402 -pre:org.ntlab.trace.FieldUpdate:1699553000331107 -post:org.ntlab.trace.FieldUpdate:1699553000331107 -post:org.ntlab.trace.MethodInvocation:1699552998548628 -pre:org.ntlab.trace.FieldUpdate:1699553000376947 -post:org.ntlab.trace.FieldUpdate:1699553000376947 -post:org.ntlab.trace.MethodInvocation:1699552997949532 -pre:org.ntlab.trace.FieldUpdate:1699553000422435 -post:org.ntlab.trace.FieldUpdate:1699553000422435 -post:org.ntlab.trace.MethodInvocation:1699552997363836 -pre:org.ntlab.trace.FieldUpdate:1699553000463691 -post:org.ntlab.trace.FieldUpdate:1699553000463691 -post:org.ntlab.trace.MethodInvocation:1699552996774613 -pre:org.ntlab.trace.FieldUpdate:1699553000508121 -post:org.ntlab.trace.FieldUpdate:1699553000508121 -post:org.ntlab.trace.MethodInvocation:1699552996163881 -pre:org.ntlab.trace.FieldUpdate:1699553000551845 -post:org.ntlab.trace.FieldUpdate:1699553000551845 -post:org.ntlab.trace.MethodInvocation:1699552995575363 -pre:org.ntlab.trace.FieldUpdate:1699553000596627 -post:org.ntlab.trace.FieldUpdate:1699553000596627 -post:org.ntlab.trace.MethodInvocation:1699552994979793 -pre:org.ntlab.trace.FieldUpdate:1699553000640352 -post:org.ntlab.trace.FieldUpdate:1699553000640352 -post:org.ntlab.trace.MethodInvocation:1699552994339441 -pre:org.ntlab.trace.FieldUpdate:1699553000682666 -post:org.ntlab.trace.FieldUpdate:1699553000682666 -pre:org.ntlab.trace.MethodInvocation:1699553001472175 -pre:org.ntlab.trace.MethodInvocation:1699553002201034 -pre:org.ntlab.trace.MethodInvocation:1699553003026510 -post:org.ntlab.trace.MethodInvocation:1699553003026510 -pre:org.ntlab.trace.FieldUpdate:1699553003101618 -post:org.ntlab.trace.FieldUpdate:1699553003101618 -post:org.ntlab.trace.MethodInvocation:1699553002201034 -pre:org.ntlab.trace.FieldUpdate:1699553003149926 -post:org.ntlab.trace.FieldUpdate:1699553003149926 -post:org.ntlab.trace.MethodInvocation:1699553001472175 -pre:org.ntlab.trace.FieldUpdate:1699553003190477 -post:org.ntlab.trace.FieldUpdate:1699553003190477 -post:org.ntlab.trace.MethodInvocation:1699552993730471 -pre:org.ntlab.trace.MethodInvocation:1699553003253243 -pre:org.ntlab.trace.BlockEnter:1699553003273695 -post:org.ntlab.trace.BlockEnter:1699553003273695 -pre:org.ntlab.trace.FieldAccess:1699553003299083 -post:org.ntlab.trace.FieldAccess:1699553003299083 -pre:org.ntlab.trace.FieldAccess:1699553003355502 -post:org.ntlab.trace.FieldAccess:1699553003355502 -pre:org.ntlab.trace.MethodInvocation:1699553003386885 -pre:org.ntlab.trace.BlockEnter:1699553003400637 -post:org.ntlab.trace.BlockEnter:1699553003400637 -pre:org.ntlab.trace.FieldAccess:1699553003436956 -post:org.ntlab.trace.FieldAccess:1699553003436956 -pre:org.ntlab.trace.MethodInvocation:1699553003482444 -pre:org.ntlab.trace.BlockEnter:1699553003500427 -post:org.ntlab.trace.BlockEnter:1699553003500427 -pre:org.ntlab.trace.FieldAccess:1699553003526169 -post:org.ntlab.trace.FieldAccess:1699553003526169 -pre:org.ntlab.trace.MethodInvocation:1699553003556141 -pre:org.ntlab.trace.BlockEnter:1699553003570951 -post:org.ntlab.trace.BlockEnter:1699553003570951 -pre:org.ntlab.trace.FieldAccess:1699553003599513 -post:org.ntlab.trace.FieldAccess:1699553003599513 -post:org.ntlab.trace.MethodInvocation:1699553003556141 -pre:org.ntlab.trace.MethodInvocation:1699553003668273 -pre:org.ntlab.trace.BlockEnter:1699553003688020 -post:org.ntlab.trace.BlockEnter:1699553003688020 -pre:org.ntlab.trace.FieldAccess:1699553003715876 -post:org.ntlab.trace.FieldAccess:1699553003715876 -post:org.ntlab.trace.MethodInvocation:1699553003668273 -post:org.ntlab.trace.MethodInvocation:1699553003482444 -pre:org.ntlab.trace.MethodInvocation:1699553003805088 -pre:org.ntlab.trace.BlockEnter:1699553003818135 -post:org.ntlab.trace.BlockEnter:1699553003818135 -pre:org.ntlab.trace.FieldAccess:1699553003846345 -post:org.ntlab.trace.FieldAccess:1699553003846345 -pre:org.ntlab.trace.MethodInvocation:1699553003896769 -pre:org.ntlab.trace.BlockEnter:1699553003912989 -post:org.ntlab.trace.BlockEnter:1699553003912989 -pre:org.ntlab.trace.FieldAccess:1699553003944020 -post:org.ntlab.trace.FieldAccess:1699553003944020 -post:org.ntlab.trace.MethodInvocation:1699553003896769 -pre:org.ntlab.trace.MethodInvocation:1699553004012075 -pre:org.ntlab.trace.BlockEnter:1699553004029706 -post:org.ntlab.trace.BlockEnter:1699553004029706 -pre:org.ntlab.trace.FieldAccess:1699553004082951 -post:org.ntlab.trace.FieldAccess:1699553004082951 -post:org.ntlab.trace.MethodInvocation:1699553004012075 -post:org.ntlab.trace.MethodInvocation:1699553003805088 -post:org.ntlab.trace.MethodInvocation:1699553003386885 -pre:org.ntlab.trace.MethodInvocation:1699553004208835 -pre:org.ntlab.trace.BlockEnter:1699553004228229 -post:org.ntlab.trace.BlockEnter:1699553004228229 -pre:org.ntlab.trace.FieldAccess:1699553004257849 -post:org.ntlab.trace.FieldAccess:1699553004257849 -pre:org.ntlab.trace.MethodInvocation:1699553004302631 -pre:org.ntlab.trace.BlockEnter:1699553004326962 -post:org.ntlab.trace.BlockEnter:1699553004326962 -pre:org.ntlab.trace.FieldAccess:1699553004373507 -post:org.ntlab.trace.FieldAccess:1699553004373507 -pre:org.ntlab.trace.MethodInvocation:1699553004418995 -pre:org.ntlab.trace.BlockEnter:1699553004434510 -post:org.ntlab.trace.BlockEnter:1699553004434510 -pre:org.ntlab.trace.FieldAccess:1699553004461661 -post:org.ntlab.trace.FieldAccess:1699553004461661 -post:org.ntlab.trace.MethodInvocation:1699553004418995 -pre:org.ntlab.trace.MethodInvocation:1699553004515964 -pre:org.ntlab.trace.BlockEnter:1699553004526543 -post:org.ntlab.trace.BlockEnter:1699553004526543 -pre:org.ntlab.trace.FieldAccess:1699553004546994 -post:org.ntlab.trace.FieldAccess:1699553004546994 -post:org.ntlab.trace.MethodInvocation:1699553004515964 -post:org.ntlab.trace.MethodInvocation:1699553004302631 -pre:org.ntlab.trace.MethodInvocation:1699553004606587 -pre:org.ntlab.trace.BlockEnter:1699553004615402 -post:org.ntlab.trace.BlockEnter:1699553004615402 -pre:org.ntlab.trace.FieldAccess:1699553004629507 -post:org.ntlab.trace.FieldAccess:1699553004629507 -pre:org.ntlab.trace.MethodInvocation:1699553004648195 -pre:org.ntlab.trace.BlockEnter:1699553004655953 -post:org.ntlab.trace.BlockEnter:1699553004655953 -pre:org.ntlab.trace.FieldAccess:1699553004670763 -post:org.ntlab.trace.FieldAccess:1699553004670763 -post:org.ntlab.trace.MethodInvocation:1699553004648195 -pre:org.ntlab.trace.MethodInvocation:1699553004703556 -pre:org.ntlab.trace.BlockEnter:1699553004712019 -post:org.ntlab.trace.BlockEnter:1699553004712019 -pre:org.ntlab.trace.FieldUpdate:1699553004728240 -post:org.ntlab.trace.FieldUpdate:1699553004728240 -post:org.ntlab.trace.MethodInvocation:1699553004703556 -post:org.ntlab.trace.MethodInvocation:1699553004606587 -post:org.ntlab.trace.MethodInvocation:1699553004208835 -post:org.ntlab.trace.MethodInvocation:1699553003253243 - */ - - // Change! -// System.out.println("===== All Statements Backward ====="); -// TracePoint tp = 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; -// dex.extract(tp, dac); -// 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; -// } -// }); - } - - private static void traverseMethodExecution(MethodExecution m) { - System.out.println(m.getSignature()); - for(Statement ms :m.getStatements()) { - if(ms instanceof FieldAccess) { - System.out.println(((FieldAccess)ms).getFieldName()); - } - } - for(MethodExecution m2: m.getChildren()) { - traverseMethodExecution(m2); - } - } -/* - * ���������� - * -===== All Statements Backward ===== -post:org.ntlab.trace.MethodInvocation:1699553003253243 -post:org.ntlab.trace.MethodInvocation:1699553004208835 -post:org.ntlab.trace.MethodInvocation:1699553004606587 -post:org.ntlab.trace.MethodInvocation:1699553004703556 -post:org.ntlab.trace.FieldUpdate:1699553004728240 -pre:org.ntlab.trace.FieldUpdate:1699553004728240 -post:org.ntlab.trace.BlockEnter:1699553004712019 -pre:org.ntlab.trace.BlockEnter:1699553004712019 -pre:org.ntlab.trace.MethodInvocation:1699553004703556 -post:org.ntlab.trace.MethodInvocation:1699553004648195 -post:org.ntlab.trace.FieldAccess:1699553004670763 -pre:org.ntlab.trace.FieldAccess:1699553004670763 -post:org.ntlab.trace.BlockEnter:1699553004655953 -pre:org.ntlab.trace.BlockEnter:1699553004655953 -pre:org.ntlab.trace.MethodInvocation:1699553004648195 -post:org.ntlab.trace.FieldAccess:1699553004629507 -pre:org.ntlab.trace.FieldAccess:1699553004629507 -post:org.ntlab.trace.BlockEnter:1699553004615402 -pre:org.ntlab.trace.BlockEnter:1699553004615402 -pre:org.ntlab.trace.MethodInvocation:1699553004606587 -post:org.ntlab.trace.MethodInvocation:1699553004302631 -post:org.ntlab.trace.MethodInvocation:1699553004515964 -post:org.ntlab.trace.FieldAccess:1699553004546994 -pre:org.ntlab.trace.FieldAccess:1699553004546994 -post:org.ntlab.trace.BlockEnter:1699553004526543 -pre:org.ntlab.trace.BlockEnter:1699553004526543 -pre:org.ntlab.trace.MethodInvocation:1699553004515964 -post:org.ntlab.trace.MethodInvocation:1699553004418995 -post:org.ntlab.trace.FieldAccess:1699553004461661 -pre:org.ntlab.trace.FieldAccess:1699553004461661 -post:org.ntlab.trace.BlockEnter:1699553004434510 -pre:org.ntlab.trace.BlockEnter:1699553004434510 -pre:org.ntlab.trace.MethodInvocation:1699553004418995 -post:org.ntlab.trace.FieldAccess:1699553004373507 -pre:org.ntlab.trace.FieldAccess:1699553004373507 -post:org.ntlab.trace.BlockEnter:1699553004326962 -pre:org.ntlab.trace.BlockEnter:1699553004326962 -pre:org.ntlab.trace.MethodInvocation:1699553004302631 -post:org.ntlab.trace.FieldAccess:1699553004257849 -pre:org.ntlab.trace.FieldAccess:1699553004257849 -post:org.ntlab.trace.BlockEnter:1699553004228229 -pre:org.ntlab.trace.BlockEnter:1699553004228229 -pre:org.ntlab.trace.MethodInvocation:1699553004208835 -post:org.ntlab.trace.MethodInvocation:1699553003386885 -post:org.ntlab.trace.MethodInvocation:1699553003805088 -post:org.ntlab.trace.MethodInvocation:1699553004012075 -post:org.ntlab.trace.FieldAccess:1699553004082951 -pre:org.ntlab.trace.FieldAccess:1699553004082951 -post:org.ntlab.trace.BlockEnter:1699553004029706 -pre:org.ntlab.trace.BlockEnter:1699553004029706 -pre:org.ntlab.trace.MethodInvocation:1699553004012075 -post:org.ntlab.trace.MethodInvocation:1699553003896769 -post:org.ntlab.trace.FieldAccess:1699553003944020 -pre:org.ntlab.trace.FieldAccess:1699553003944020 -post:org.ntlab.trace.BlockEnter:1699553003912989 -pre:org.ntlab.trace.BlockEnter:1699553003912989 -pre:org.ntlab.trace.MethodInvocation:1699553003896769 -post:org.ntlab.trace.FieldAccess:1699553003846345 -pre:org.ntlab.trace.FieldAccess:1699553003846345 -post:org.ntlab.trace.BlockEnter:1699553003818135 -pre:org.ntlab.trace.BlockEnter:1699553003818135 -pre:org.ntlab.trace.MethodInvocation:1699553003805088 -post:org.ntlab.trace.MethodInvocation:1699553003482444 -post:org.ntlab.trace.MethodInvocation:1699553003668273 -post:org.ntlab.trace.FieldAccess:1699553003715876 -pre:org.ntlab.trace.FieldAccess:1699553003715876 -post:org.ntlab.trace.BlockEnter:1699553003688020 -pre:org.ntlab.trace.BlockEnter:1699553003688020 -pre:org.ntlab.trace.MethodInvocation:1699553003668273 -post:org.ntlab.trace.MethodInvocation:1699553003556141 -post:org.ntlab.trace.FieldAccess:1699553003599513 -pre:org.ntlab.trace.FieldAccess:1699553003599513 -post:org.ntlab.trace.BlockEnter:1699553003570951 -pre:org.ntlab.trace.BlockEnter:1699553003570951 -pre:org.ntlab.trace.MethodInvocation:1699553003556141 -post:org.ntlab.trace.FieldAccess:1699553003526169 -pre:org.ntlab.trace.FieldAccess:1699553003526169 -post:org.ntlab.trace.BlockEnter:1699553003500427 -pre:org.ntlab.trace.BlockEnter:1699553003500427 -pre:org.ntlab.trace.MethodInvocation:1699553003482444 -post:org.ntlab.trace.FieldAccess:1699553003436956 -pre:org.ntlab.trace.FieldAccess:1699553003436956 -post:org.ntlab.trace.BlockEnter:1699553003400637 -pre:org.ntlab.trace.BlockEnter:1699553003400637 -pre:org.ntlab.trace.MethodInvocation:1699553003386885 -post:org.ntlab.trace.FieldAccess:1699553003355502 -pre:org.ntlab.trace.FieldAccess:1699553003355502 -post:org.ntlab.trace.FieldAccess:1699553003299083 -pre:org.ntlab.trace.FieldAccess:1699553003299083 -post:org.ntlab.trace.BlockEnter:1699553003273695 -pre:org.ntlab.trace.BlockEnter:1699553003273695 -pre:org.ntlab.trace.MethodInvocation:1699553003253243 -post:org.ntlab.trace.MethodInvocation:1699552993730471 -post:org.ntlab.trace.FieldUpdate:1699553003190477 -pre:org.ntlab.trace.FieldUpdate:1699553003190477 -post:org.ntlab.trace.MethodInvocation:1699553001472175 -post:org.ntlab.trace.FieldUpdate:1699553003149926 -pre:org.ntlab.trace.FieldUpdate:1699553003149926 -post:org.ntlab.trace.MethodInvocation:1699553002201034 -post:org.ntlab.trace.FieldUpdate:1699553003101618 -pre:org.ntlab.trace.FieldUpdate:1699553003101618 -post:org.ntlab.trace.MethodInvocation:1699553003026510 -pre:org.ntlab.trace.MethodInvocation:1699553003026510 -pre:org.ntlab.trace.MethodInvocation:1699553002201034 -pre:org.ntlab.trace.MethodInvocation:1699553001472175 -post:org.ntlab.trace.FieldUpdate:1699553000682666 -pre:org.ntlab.trace.FieldUpdate:1699553000682666 -post:org.ntlab.trace.MethodInvocation:1699552994339441 -post:org.ntlab.trace.FieldUpdate:1699553000640352 -pre:org.ntlab.trace.FieldUpdate:1699553000640352 -post:org.ntlab.trace.MethodInvocation:1699552994979793 -post:org.ntlab.trace.FieldUpdate:1699553000596627 -pre:org.ntlab.trace.FieldUpdate:1699553000596627 -post:org.ntlab.trace.MethodInvocation:1699552995575363 -post:org.ntlab.trace.FieldUpdate:1699553000551845 -pre:org.ntlab.trace.FieldUpdate:1699553000551845 -post:org.ntlab.trace.MethodInvocation:1699552996163881 -post:org.ntlab.trace.FieldUpdate:1699553000508121 -pre:org.ntlab.trace.FieldUpdate:1699553000508121 -post:org.ntlab.trace.MethodInvocation:1699552996774613 -post:org.ntlab.trace.FieldUpdate:1699553000463691 -pre:org.ntlab.trace.FieldUpdate:1699553000463691 -post:org.ntlab.trace.MethodInvocation:1699552997363836 -post:org.ntlab.trace.FieldUpdate:1699553000422435 -pre:org.ntlab.trace.FieldUpdate:1699553000422435 -post:org.ntlab.trace.MethodInvocation:1699552997949532 -post:org.ntlab.trace.FieldUpdate:1699553000376947 -pre:org.ntlab.trace.FieldUpdate:1699553000376947 -post:org.ntlab.trace.MethodInvocation:1699552998548628 -post:org.ntlab.trace.FieldUpdate:1699553000331107 -pre:org.ntlab.trace.FieldUpdate:1699553000331107 -post:org.ntlab.trace.MethodInvocation:1699552999050402 -post:org.ntlab.trace.FieldUpdate:1699553000290908 -pre:org.ntlab.trace.FieldUpdate:1699553000290908 -post:org.ntlab.trace.MethodInvocation:1699552999466490 -post:org.ntlab.trace.FieldUpdate:1699553000259878 -pre:org.ntlab.trace.FieldUpdate:1699553000259878 -post:org.ntlab.trace.MethodInvocation:1699552999875526 -post:org.ntlab.trace.FieldUpdate:1699553000225322 -pre:org.ntlab.trace.FieldUpdate:1699553000225322 -post:org.ntlab.trace.MethodInvocation:1699553000173135 -pre:org.ntlab.trace.MethodInvocation:1699553000173135 -pre:org.ntlab.trace.MethodInvocation:1699552999875526 -pre:org.ntlab.trace.MethodInvocation:1699552999466490 -pre:org.ntlab.trace.MethodInvocation:1699552999050402 -pre:org.ntlab.trace.MethodInvocation:1699552998548628 -pre:org.ntlab.trace.MethodInvocation:1699552997949532 -pre:org.ntlab.trace.MethodInvocation:1699552997363836 -pre:org.ntlab.trace.MethodInvocation:1699552996774613 -pre:org.ntlab.trace.MethodInvocation:1699552996163881 -pre:org.ntlab.trace.MethodInvocation:1699552995575363 -pre:org.ntlab.trace.MethodInvocation:1699552994979793 -pre:org.ntlab.trace.MethodInvocation:1699552994339441 -pre:org.ntlab.trace.MethodInvocation:1699552993730471 -post:org.ntlab.trace.BlockEnter:1699552992988213 -pre:org.ntlab.trace.BlockEnter:1699552992988213 - */ -}