diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 53c7d1ac..ca6940be 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -543,6 +543,7 @@ public class FamilyOfGeneratedGenerics { oldConsListConverted.add(new TPHConstraint(((TypePlaceholder) pair.TA1).getName(), ((TypePlaceholder) pair.TA2).getName(), r)); } List tcOfoldCons = buildTransitiveClosure(oldConsListConverted); + Set tcOfoldConsSet = buildTransitiveClosureForCP(oldCons); for(int i=0; i extendsList = orConsListConverted.get(i).get(Relation.EXTENDS); @@ -563,6 +564,38 @@ public class FamilyOfGeneratedGenerics { return tempMC; } + public static Set buildTransitiveClosureForCP(Set constraint) { + Set iterSet = new HashSet<>(constraint); + Set runSet = new HashSet<>(constraint); + Set tcSet = new HashSet<>(constraint); + boolean addedConToList = false; +// for (TPHConstraint cons: iterList) { + Iterator itIterSet = iterSet.iterator(); + while(itIterSet.hasNext()) { + Pair pairIterSet = itIterSet.next(); +// for (TPHConstraint cons2: runList) { + Iterator itRunSet = runSet.iterator(); + while (itRunSet.hasNext()) { + Pair pairRunSet = itRunSet.next(); +// if(cons.getRight() == cons2.getLeft()) { + if(pairIterSet.TA2 == pairRunSet.TA1) { +// TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS); + Pair p = new Pair(pairIterSet.TA1, pairRunSet.TA2); +// if (!checkForDuplicates(consToAdd,tcList)) { + if(!tcSet.contains(p)) { +// tcList.add(consToAdd); + tcSet.add(p); + addedConToList = true; + if (addedConToList) { + return buildTransitiveClosureForCP(tcSet); + } + } + } + } + } + return tcSet; + } + public static HashMap> getMethodConstraintsWithPositionNew(List cs, List cs_cl, HashMap>> posOfTphs, List listOfMethodsAndTph, ResultSet resSet, Set oldCons) { HashMap> tempMethodConstraintsWithPosition = new HashMap<>(); List newMCList = new ArrayList<>();