From db149eb5884d2b28be3c9737895d239902668e98 Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Fri, 26 Mar 2021 16:15:18 +0100 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java klein Korrekturen modified: src/test/java/insertGenerics/TestTwoArgs2.java List -> Set --- .../insertGenerics/FamilyOfGeneratedGenerics.java | 7 +++---- src/test/java/insertGenerics/TestTwoArgs2.java | 15 +++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 3f98a42b..ede2b1b6 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -662,8 +662,7 @@ public class FamilyOfGeneratedGenerics { Iterator itUndCons = undCons.iterator(); while (itUndCons.hasNext()) { Pair pairUndCons2 = itUndCons.next(); - boolean rEqRtilde = (tphR == pairUndCons2.TA1); - boolean rExRtilde = (tphR == pairUndCons2.TA1); + boolean rEqExRtilde = (tphR == pairUndCons2.TA1); // Pair rExRtildePair = new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT); boolean isPairInTExTapostrophe = false; // Constraint allOfOr = new Constraint(); @@ -675,14 +674,14 @@ public class FamilyOfGeneratedGenerics { while(itCP.hasNext()) { Pair p = itCP.next(); if(p.OperatorSmallerDot()) { - isPairInTExTapostrophe = tphR == p.TA1; + isPairInTExTapostrophe = isPairInTExTapostrophe || tphR.equals(p.TA1); } } } } - if (rEqRtilde || rExRtilde || isPairInTExTapostrophe) { + if (rEqExRtilde || isPairInTExTapostrophe) { if (newPair2.TA1 != newPair2.TA2) { //eliminieren der Fälle wie AA<.AA if (!checkForDuplicatesForSets(newPair2, tempSet2)) tempSet2.add(newPair2); diff --git a/src/test/java/insertGenerics/TestTwoArgs2.java b/src/test/java/insertGenerics/TestTwoArgs2.java index 42a5a833..780a4401 100644 --- a/src/test/java/insertGenerics/TestTwoArgs2.java +++ b/src/test/java/insertGenerics/TestTwoArgs2.java @@ -56,15 +56,15 @@ public class TestTwoArgs2 { List classConstraintsTest = new ArrayList<>(); classConstraintsTest.add(new ClassConstraint("N", "java/lang/Object", Relation.EXTENDS)); - HashMap> methodConstraintsWithPositionTest = new HashMap<>(); - List lmc; - lmc = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); lmc.add(new MethodConstraint("AG", "AA", Relation.EXTENDS)); lmc.add(new MethodConstraint("U", "P", Relation.EXTENDS)); lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS)); lmc.add(new MethodConstraint("AA", "java/lang/Object", Relation.EXTENDS)); methodConstraintsWithPositionTest.put("TPH AAm(TPH AATPH U)", lmc); - lmc = new ArrayList<>(); + lmc = new HashSet<>(); lmc.add(new MethodConstraint("AB", "P", Relation.EXTENDS)); lmc.add(new MethodConstraint("AC", "U", Relation.EXTENDS)); lmc.add(new MethodConstraint("AB", "AA", Relation.EXTENDS)); @@ -73,7 +73,7 @@ public class TestTwoArgs2 { lmc.add(new MethodConstraint("U", "AA", Relation.EXTENDS)); lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS)); methodConstraintsWithPositionTest.put("TPH AAmain(TPH ABTPH AC)", lmc); - lmc = new ArrayList<>(); + lmc = new HashSet<>(); lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS)); lmc.add(new MethodConstraint("AG", "java/lang/Object", Relation.EXTENDS)); methodConstraintsWithPositionTest.put("TPH AGid(TPH P)", lmc); @@ -84,7 +84,10 @@ public class TestTwoArgs2 { assertEquals(expectedClassCons, computedClassCons); - assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition); + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});