diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 4cde842ff..5aafb37ae 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -181,11 +181,11 @@ public class FamilyOfGeneratedGenerics { if (!checkForDuplicates(consToAdd, tempCC)) { tempCC.add(consToAdd); } - }else if(pair.fst == PositionFinder.Position.FIELD){ + /*}else if(pair.fst == PositionFinder.Position.FIELD){ ClassConstraint consToAdd = new ClassConstraint(tph, objectType, Relation.EXTENDS); if (!checkForDuplicates(consToAdd, tempCC)) { tempCC.add(consToAdd); - } + }*/ } } } @@ -496,8 +496,10 @@ public class FamilyOfGeneratedGenerics { r = Relation.EQUAL; } MethodConstraint mc = new MethodConstraint(ta1, ta2, r); - if(!checkForDuplicates(mc, tempMC)) { - tempMC.add(mc); + if(mc.getRel() != Relation.EQUAL) { + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + } } } return tempMC; @@ -523,14 +525,17 @@ public class FamilyOfGeneratedGenerics { if(p.GetOperator() == PairOperator.SMALLERDOT) { r = Relation.EXTENDS; orConsWithEXTENDS.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r)); - tempMC.add(new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r)); - } else if(p.GetOperator() == PairOperator.EQUALSDOT) { - r = Relation.EQUAL; - orConsWithEQUAL.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r)); MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r); if(!checkForDuplicates(mc, tempMC)) { tempMC.add(mc); } + } else if(p.GetOperator() == PairOperator.EQUALSDOT) { + r = Relation.EQUAL; + orConsWithEQUAL.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r)); + /*MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r); + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + }*/ } } } @@ -586,8 +591,10 @@ public class FamilyOfGeneratedGenerics { // if (tc.getLeft() == mc.getLeft() && tc.getRight() == mc.getRight() && tc.getRel() == mc.getRel()) { if(resSet.resolveType((TypePlaceholder)(pairTC.TA1)).resolvedType == newPair.TA1 && resSet.resolveType((TypePlaceholder)(pairTC.TA2)).resolvedType == newPair.TA2 && pairTC.OperatorSmallerDot() && newPair.OperatorSmallerDot()) { //hier bei pairTC resolvedType, damit Pairs aus oldCons in der Methode zur Berechnung von der transitiven Hülle nicht in eine Endlosschleife kommen (Cycles!) // if (!checkForDuplicates(mc, tempMC)) { - if(!checkForDuplicatesForSets(newPair, tempSet)) { - tempSet.add(newPair); + if(newPair.TA1 != newPair.TA2) { + if (!checkForDuplicatesForSets(newPair, tempSet)) { + tempSet.add(newPair); + } } } } @@ -608,8 +615,10 @@ public class FamilyOfGeneratedGenerics { r = Relation.EQUAL; } MethodConstraint mc = new MethodConstraint(ta1, ta2, r); - if(!checkForDuplicates(mc, tempMC)) { - tempMC.add(mc); + if(mc.getRel() != Relation.EQUAL) { + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + } } } @@ -669,10 +678,33 @@ public class FamilyOfGeneratedGenerics { return false; } + public static List hasNoSupertypeForMethodTypesNew(List allConstraints, HashMap>> posOfTphs, MethodAndTPH methodAndTPH) { + List tempMC = new ArrayList<>(); + List allCons = allConstraints; + MethodAndTPH methAndTphs = methodAndTPH; + for(String tph: posOfTphs.keySet()) { + for(int i=0; i> getMethodConstraintsWithPositionNew(List cs, List cs_cl, HashMap>> posOfTphs, List listOfMethodsAndTph, ResultSet resSet, Set oldCons) { HashMap> tempMethodConstraintsWithPosition = new HashMap<>(); List newMCList = new ArrayList<>(); List newMCList2 = new ArrayList<>(); + List hasNoSupType = new ArrayList<>(); + List mcWithoutCc = new ArrayList<>(); + List methodsAddedToHashMap = new ArrayList<>(); for(MethodAndTPH method: listOfMethodsAndTph){ String currentMethod = method.getId(); @@ -704,7 +736,25 @@ public class FamilyOfGeneratedGenerics { tempMethodConstraintsWithPosition.put(currentMethod, newMCList2); }*/ - tempMethodConstraintsWithPosition.put(currentMethod, listToAdd); + hasNoSupType = hasNoSupertypeForMethodTypesNew(cs,posOfTphs,method); + for (MethodConstraint cons: hasNoSupType) { + if (!checkForDuplicates(cons, listToAdd)) { + listToAdd.add(cons); + } + } + + mcWithoutCc = methodTypesWithoutClassTypes(cs_cl, listToAdd); + + tempMethodConstraintsWithPosition.put(currentMethod, mcWithoutCc); + } + for(String curMeth: tempMethodConstraintsWithPosition.keySet()){ + for(int i=0; i