Merge branch 'bytecodeGenericsSecond' of ssh://gohorb.ba-horb.de/bahome/projekt/git/JavaCompilerCore into bytecodeGenericsSecond

This commit is contained in:
pl@gohorb.ba-horb.de 2021-01-29 12:29:24 +01:00
commit ebfc3dedbe
4 changed files with 90 additions and 65 deletions

View File

@ -12,7 +12,7 @@ import java.util.List;
public class FamilyOfGeneratedGenerics { public class FamilyOfGeneratedGenerics {
public List<TPHConstraint> allConstraints = new ArrayList<>(); public List<TPHConstraint> allConstraints = new ArrayList<>();
// HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode // HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode
public HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTPHs = new HashMap<>(); public HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTPHs = new HashMap<>();
public List<ClassConstraint> classConstraints = new ArrayList<>(); public List<ClassConstraint> classConstraints = new ArrayList<>();
public List<MethodConstraint> methodConstraints = new ArrayList<>(); public List<MethodConstraint> methodConstraints = new ArrayList<>();
public HashMap<String, List<MethodConstraint>> methodConstraintsWithPosition = new HashMap<>(); public HashMap<String, List<MethodConstraint>> methodConstraintsWithPosition = new HashMap<>();
@ -22,11 +22,11 @@ public class FamilyOfGeneratedGenerics {
this.allConstraints = tphExtractor.allCons; this.allConstraints = tphExtractor.allCons;
this.posOfTPHs = positionConverter(tphExtractor.allTPHS, tphExtractor.ListOfMethodsAndTph); this.posOfTPHs = positionConverter(tphExtractor.allTPHS, tphExtractor.ListOfMethodsAndTph);
this.classConstraints = getClassConstraints(allConstraints,posOfTPHs); this.classConstraints = getClassConstraints(allConstraints,posOfTPHs);
// this.methodConstraints = getMethodConstraints(allConstraints,classConstraints,posOfTPHs); this.methodConstraints = getMethodConstraints(allConstraints,classConstraints,posOfTPHs, tphExtractor.ListOfMethodsAndTph);
this.methodConstraintsWithPosition = getMethodConstraintsWithPosition(allConstraints,classConstraints,posOfTPHs, tphExtractor.ListOfMethodsAndTph); this.methodConstraintsWithPosition = getMethodConstraintsWithPosition(allConstraints,classConstraints,posOfTPHs, tphExtractor.ListOfMethodsAndTph);
} }
public static List<ClassConstraint> getClassConstraints(List<TPHConstraint> cs, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { //Inputparameter List<TPHConstraint> constraintsSet weg public static List<ClassConstraint> getClassConstraints(List<TPHConstraint> cs, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) { //Inputparameter List<TPHConstraint> constraintsSet weg
List<ClassConstraint> cs_cl = new ArrayList<>(); List<ClassConstraint> cs_cl = new ArrayList<>();
List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(cs, posOfTphs); List<ClassConstraint> classConstraints1 = typeOfANodeOfAField(cs, posOfTphs);
for (ClassConstraint cons: classConstraints1) { for (ClassConstraint cons: classConstraints1) {
@ -57,7 +57,7 @@ public class FamilyOfGeneratedGenerics {
return cs_cl; return cs_cl;
} }
public static List<MethodConstraint> getMethodConstraints(List<TPHConstraint> cs, List<ClassConstraint> cs_cl, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph) { public static List<MethodConstraint> getMethodConstraints(List<TPHConstraint> cs, List<ClassConstraint> cs_cl, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph) {
List<MethodConstraint> cs_m = new ArrayList<>(); List<MethodConstraint> cs_m = new ArrayList<>();
List<MethodConstraint> methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs); List<MethodConstraint> methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs);
for (MethodConstraint cons: methodConstraints1) { for (MethodConstraint cons: methodConstraints1) {
@ -102,7 +102,7 @@ public class FamilyOfGeneratedGenerics {
return cs_m; return cs_m;
} }
public static HashMap<String, List<MethodConstraint>> getMethodConstraintsWithPosition(List<TPHConstraint> cs, List<ClassConstraint> cs_cl, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph) { public static HashMap<String, List<MethodConstraint>> getMethodConstraintsWithPosition(List<TPHConstraint> cs, List<ClassConstraint> cs_cl, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph) {
HashMap<String, List<MethodConstraint>> tempMethodConstraintsWithPosition = new HashMap<>(); HashMap<String, List<MethodConstraint>> tempMethodConstraintsWithPosition = new HashMap<>();
for(MethodAndTPH method: listOfMethodsAndTph){ for(MethodAndTPH method: listOfMethodsAndTph){
List<String> methodsAddedToHashMap = new ArrayList<>(); List<String> methodsAddedToHashMap = new ArrayList<>();
@ -112,10 +112,12 @@ public class FamilyOfGeneratedGenerics {
methodsAddedToHashMap.add(currentMethod); methodsAddedToHashMap.add(currentMethod);
containsCurrentMethod = true; containsCurrentMethod = true;
List<MethodConstraint> listOfThisMethod = new ArrayList<>(); List<MethodConstraint> listOfThisMethod = new ArrayList<>();
HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTPHsForThisMethod = new HashMap<>(); HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTPHsForThisMethod = new HashMap<>();
for(String s: posOfTphs.keySet()) { for(String s: posOfTphs.keySet()) {
if(posOfTphs.get(s).snd == currentMethod && posOfTphs.get(s).snd != null) { for(PairTphMethod pair: posOfTphs.get(s)) {
posOfTPHsForThisMethod.put(s,posOfTphs.get(s)); if(pair.snd == currentMethod && pair.snd != null) {
posOfTPHsForThisMethod.put(s,posOfTphs.get(s));
}
} }
} }
listOfThisMethod = getMethodConstraints(cs,cs_cl,posOfTPHsForThisMethod,listOfMethodsAndTph); listOfThisMethod = getMethodConstraints(cs,cs_cl,posOfTPHsForThisMethod,listOfMethodsAndTph);
@ -150,16 +152,18 @@ public class FamilyOfGeneratedGenerics {
* Def. FGG: erste Zeile von cs_cl * Def. FGG: erste Zeile von cs_cl
* {T < .T' | T is a type variable in a type of a node of a field} * {T < .T' | T is a type variable in a type of a node of a field}
*/ */
public static List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> allConstraints, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { public static List<ClassConstraint> typeOfANodeOfAField(List<TPHConstraint> allConstraints, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) {
//RuntimeException re = new RuntimeException("enthält EQUALS-Relation"); //RuntimeException re = new RuntimeException("enthält EQUALS-Relation");
List<ClassConstraint> tempCC = new ArrayList<>(); List<ClassConstraint> tempCC = new ArrayList<>();
for(TPHConstraint allCons: allConstraints){ for(TPHConstraint allCons: allConstraints){
if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) { if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) {
for(String tph: posOfTphs.keySet()) { for(String tph: posOfTphs.keySet()) {
if(tph == allCons.getLeft() && posOfTphs.get(tph).fst == PositionFinder.Position.FIELD) { for(PairTphMethod pair: posOfTphs.get(tph)) {
ClassConstraint consToAdd = new ClassConstraint(tph, allCons.getRight(), allCons.getRel()); if(tph == allCons.getLeft() && pair.fst == PositionFinder.Position.FIELD) {
if (!checkForDuplicates(consToAdd, tempCC)) { ClassConstraint consToAdd = new ClassConstraint(tph, allCons.getRight(), allCons.getRel());
tempCC.add(consToAdd); if (!checkForDuplicates(consToAdd, tempCC)) {
tempCC.add(consToAdd);
}
} }
} }
} }
@ -198,18 +202,20 @@ public class FamilyOfGeneratedGenerics {
* {T <. Object | ((T is a type variable in a type of a node of a field * {T <. Object | ((T is a type variable in a type of a node of a field
* or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)} * or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)}
*/ */
public static List<ClassConstraint> hasNoSupertypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { public static List<ClassConstraint> hasNoSupertypeForClassTypes(List<TPHConstraint> allConstraints, List<ClassConstraint> cs_cl, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) {
List<ClassConstraint> tempCC= new ArrayList<>(); List<ClassConstraint> tempCC= new ArrayList<>();
for(TPHConstraint allCons: allConstraints) { for(TPHConstraint allCons: allConstraints) {
for(ClassConstraint cCons: cs_cl) { for(ClassConstraint cCons: cs_cl) {
for(String tph: posOfTphs.keySet()) { for(String tph: posOfTphs.keySet()) {
boolean tvInField = posOfTphs.get(tph).fst == PositionFinder.Position.FIELD; for(PairTphMethod pair: posOfTphs.get(tph)) {
boolean hasSmallerTVInClCons = (posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null); boolean tvInField = pair.fst == PositionFinder.Position.FIELD;
if( ((tvInField || hasSmallerTVInClCons) && cCons.getRel()==Relation.EXTENDS) && boolean hasSmallerTVInClCons = (posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null);
!checkUpperBound(allConstraints, tph) && allCons.getRel()==Relation.EXTENDS) { if( ((tvInField || hasSmallerTVInClCons) && cCons.getRel()==Relation.EXTENDS) &&
ClassConstraint consToAdd = new ClassConstraint(tph, "Object", Relation.EXTENDS); !checkUpperBound(allConstraints, tph) && allCons.getRel()==Relation.EXTENDS) {
if (!checkForDuplicates(consToAdd, tempCC)){ ClassConstraint consToAdd = new ClassConstraint(tph, "Object", Relation.EXTENDS);
tempCC.add(consToAdd); if (!checkForDuplicates(consToAdd, tempCC)){
tempCC.add(consToAdd);
}
} }
} }
} }
@ -222,16 +228,18 @@ public class FamilyOfGeneratedGenerics {
* Def. FGG: erste Zeile von cs_m * Def. FGG: erste Zeile von cs_m
* {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs} * {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs}
*/ */
public static List<MethodConstraint> typeOfTheMethodInClSigma(List<TPHConstraint> allConstraints, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs) { // cl_\sigma?? public static List<MethodConstraint> typeOfTheMethodInClSigma(List<TPHConstraint> allConstraints, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs) { // cl_\sigma??
//TODO: //TODO:
List<MethodConstraint> tempMC= new ArrayList<>(); List<MethodConstraint> tempMC= new ArrayList<>();
for(TPHConstraint allCons: allConstraints){ for(TPHConstraint allCons: allConstraints){
if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) { if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) {
for(String tph: posOfTphs.keySet()) { for(String tph: posOfTphs.keySet()) {
if(tph == allCons.getLeft() && (posOfTphs.get(tph).fst == PositionFinder.Position.METHOD || posOfTphs.get(tph).fst == PositionFinder.Position.CONSTRUCTOR)) { for(PairTphMethod pair: posOfTphs.get(tph)) {
MethodConstraint consToAdd = new MethodConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); if(tph == allCons.getLeft() && (pair.fst == PositionFinder.Position.METHOD || pair.fst == PositionFinder.Position.CONSTRUCTOR)) {
if (!checkForDuplicates(consToAdd, tempMC)) { MethodConstraint consToAdd = new MethodConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel());
tempMC.add(consToAdd); if (!checkForDuplicates(consToAdd, tempMC)) {
tempMC.add(consToAdd);
}
} }
} }
} }
@ -297,32 +305,34 @@ public class FamilyOfGeneratedGenerics {
* {T <. Object | (T is a type variable in a type of a node of the method/constructor m in cl_\sigma), * {T <. Object | (T is a type variable in a type of a node of the method/constructor m in cl_\sigma),
* (\existsnot T': T <. T') \in cs)} * (\existsnot T': T <. T') \in cs)}
*/ */
public static List<MethodConstraint> hasNoSupertypeForMethodTypes(List<TPHConstraint> allConstraints, List<MethodConstraint> cs_m, HashMap<String, PairTphMethod<PositionFinder.Position, String>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph) { public static List<MethodConstraint> hasNoSupertypeForMethodTypes(List<TPHConstraint> allConstraints, List<MethodConstraint> cs_m, HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> posOfTphs, List<MethodAndTPH> listOfMethodsAndTph) {
//TODO: //TODO:
List<MethodConstraint> tempMC= new ArrayList<>(); List<MethodConstraint> tempMC= new ArrayList<>();
for(String tph: posOfTphs.keySet()) { for(String tph: posOfTphs.keySet()) {
for(TPHConstraint allCons: allConstraints) { for(PairTphMethod pair: posOfTphs.get(tph)) {
if((posOfTphs.get(tph).fst.equals(PositionFinder.Position.METHOD) || posOfTphs.get(tph).fst.equals(PositionFinder.Position.CONSTRUCTOR)) && !checkUpperBound(allConstraints,tph)) { for(TPHConstraint allCons: allConstraints) {
MethodConstraint consToAdd = new MethodConstraint(tph, "Object", Relation.EXTENDS); if((pair.fst.equals(PositionFinder.Position.METHOD) || pair.fst.equals(PositionFinder.Position.CONSTRUCTOR)) && !checkUpperBound(allConstraints,tph)) {
if (!checkForDuplicates(consToAdd, tempMC)) {
tempMC.add(consToAdd);
}
}
}
List<TPHConstraint> tempMCObject1 = new ArrayList<>(cs_m);
String currentMethod = "";
for(MethodAndTPH mat: listOfMethodsAndTph) {
if(mat.getId().equals(posOfTphs.get(tph).snd)) {
currentMethod = mat.getId();
}
for(TPHConstraint mc1: tempMCObject1) {
if(tph==mc1.getRight() && !checkUpperBound(tempMCObject1,tph)) {
MethodConstraint consToAdd = new MethodConstraint(tph, "Object", Relation.EXTENDS); MethodConstraint consToAdd = new MethodConstraint(tph, "Object", Relation.EXTENDS);
if (!checkForDuplicates(consToAdd, tempMC)) { if (!checkForDuplicates(consToAdd, tempMC)) {
tempMC.add(consToAdd); tempMC.add(consToAdd);
} }
} }
} }
List<TPHConstraint> tempMCObject1 = new ArrayList<>(cs_m);
String currentMethod = "";
for(MethodAndTPH mat: listOfMethodsAndTph) {
if(mat.getId().equals(pair.snd)) {
currentMethod = mat.getId();
}
for(TPHConstraint mc1: tempMCObject1) {
if(tph==mc1.getRight() && !checkUpperBound(tempMCObject1,tph)) {
MethodConstraint consToAdd = new MethodConstraint(tph, "Object", Relation.EXTENDS);
if (!checkForDuplicates(consToAdd, tempMC)) {
tempMC.add(consToAdd);
}
}
}
}
} }
} }
return tempMC; return tempMC;
@ -410,18 +420,20 @@ public class FamilyOfGeneratedGenerics {
} }
public static HashMap<String, PairTphMethod<PositionFinder.Position, String>> positionConverter(HashMap<String, Boolean> allTphs, List<MethodAndTPH> listOfMethodsAndTphs) { public static HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> positionConverter(HashMap<String, Boolean> allTphs, List<MethodAndTPH> listOfMethodsAndTphs) {
HashMap<String, PairTphMethod<PositionFinder.Position, String>> convertedPositions = new HashMap<>(); HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> convertedPositions = new HashMap<>();
for(String tph: allTphs.keySet()) { for(String tph: allTphs.keySet()) {
List<PairTphMethod<PositionFinder.Position, String>> currMeth = new ArrayList<>();
if(allTphs.get(tph)) { //if true, then tph is a method-TPH if(allTphs.get(tph)) { //if true, then tph is a method-TPH
for(MethodAndTPH methTph: listOfMethodsAndTphs) { for(MethodAndTPH methTph: listOfMethodsAndTphs) {
if (methTph.getTphs().contains(tph)) { if (methTph.getTphs().contains(tph)) {
convertedPositions.put(tph, new PairTphMethod<>(PositionFinder.Position.METHOD, methTph.getId())); currMeth.add(new PairTphMethod<>(PositionFinder.Position.METHOD, methTph.getId()));
} }
} }
} else { // else it is in the class-TPH } else { // else it is in the class-TPH
convertedPositions.put(tph, new PairTphMethod<>(PositionFinder.Position.FIELD, null)); currMeth.add(new PairTphMethod<>(PositionFinder.Position.FIELD, null));
} }
convertedPositions.put(tph, currMeth);
} }
return convertedPositions; return convertedPositions;
} }

View File

@ -1,3 +1,4 @@
/*
package insertGenerics; package insertGenerics;
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
@ -12,11 +13,13 @@ import java.util.List;
public class FamilyOfGeneratedGenericsTest extends TestCase { public class FamilyOfGeneratedGenericsTest extends TestCase {
public void testIdentityMethod(){ public void testIdentityMethod(){
/* */
/*
Example method: Example method:
A id(B i) return i; A id(B i) return i;
gives constraint: B <. A and A <. Object, which are method constraints gives constraint: B <. A and A <. Object, which are method constraints
*/ *//*
List<TPHConstraint> inputConstraints = new ArrayList<>(); List<TPHConstraint> inputConstraints = new ArrayList<>();
inputConstraints.add(new TPHConstraint("B", "A", TPHConstraint.Relation.EXTENDS)); inputConstraints.add(new TPHConstraint("B", "A", TPHConstraint.Relation.EXTENDS));
@ -29,9 +32,11 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
assertTrue(classConstraints.isEmpty()); assertTrue(classConstraints.isEmpty());
/* */
/*
MethodConstraints should be the same as the input constraint MethodConstraints should be the same as the input constraint
*/ *//*
// List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, new ArrayList<ClassConstraint>(), tphPositions); // List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, new ArrayList<ClassConstraint>(), tphPositions);
// assertTrue(methodConstraints.size() == 2); // assertTrue(methodConstraints.size() == 2);
// assertTrue(methodConstraints.get(0).getLeft().equals("B")); // assertTrue(methodConstraints.get(0).getLeft().equals("B"));
@ -39,7 +44,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
} }
public void testClassField(){ public void testClassField(){
/* */
/*
class Example{ class Example{
A f; A f;
B fReturn(){ B fReturn(){
@ -47,7 +53,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
} }
} }
gives constraint: A <. B and B <. Object which are class constraints gives constraint: A <. B and B <. Object which are class constraints
*/ *//*
List<TPHConstraint> inputConstraints = new ArrayList<>(); List<TPHConstraint> inputConstraints = new ArrayList<>();
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
@ -58,9 +65,11 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.METHOD, "fReturn"); PairTphMethod<PositionFinder.Position, String> posOfB = new PairTphMethod<>(PositionFinder.Position.METHOD, "fReturn");
tphPositions.put("B", posOfB); tphPositions.put("B", posOfB);
/* */
/*
ClassConstraints should not be the same as the input constraint ClassConstraints should not be the same as the input constraint
*/ *//*
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
System.out.println(classConstraints); System.out.println(classConstraints);
assertTrue(classConstraints.size() == 2); assertTrue(classConstraints.size() == 2);
@ -70,7 +79,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
} }
public void testSecondLineOfClassConstraints() { public void testSecondLineOfClassConstraints() {
/* */
/*
class Example() { class Example() {
A a; A a;
B b = a; B b = a;
@ -84,7 +94,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
return e; return e;
} }
} }
*/ *//*
List<TPHConstraint> inputConstraints = new ArrayList<>(); List<TPHConstraint> inputConstraints = new ArrayList<>();
inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS));
@ -120,7 +131,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
} }
public void testTPHsAndGenerics() { public void testTPHsAndGenerics() {
/* */
/*
class TPHsAndGenerics { class TPHsAndGenerics {
Fun1<A,B> id = x -> x; Fun1<A,B> id = x -> x;
C id2 (D x) { C id2 (D x) {
@ -134,7 +146,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
return b; return b;
} }
} }
*/ *//*
List<TPHConstraint> inputConstraints = new ArrayList<>(); List<TPHConstraint> inputConstraints = new ArrayList<>();
inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS)); inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS));
@ -196,7 +209,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
HashMap<String, PairTphMethod<PositionFinder.Position, String>> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs); HashMap<String, List<PairTphMethod<PositionFinder.Position, String>>> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs);
System.out.println(allTphsNew); System.out.println(allTphsNew);
//was tun wenn zwei (oder mehr) Methoden gleiches TPH enthalten? //was tun wenn zwei (oder mehr) Methoden gleiches TPH enthalten?
//ist dies möglich oder werden die TPHs immer verschieden initialisiert und dann erst am Ende gemappt? //ist dies möglich oder werden die TPHs immer verschieden initialisiert und dann erst am Ende gemappt?
@ -212,4 +225,4 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
} }
} }*/

View File

@ -52,8 +52,8 @@ public class TestExample42 {
@Test @Test
public void genericTest() { public void genericTest() {
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs()); // List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs());
System.out.println("ClassConstraints: " + classConstraints); // System.out.println("ClassConstraints: " + classConstraints);
// List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),classConstraints,fillPosOfTphs()); // List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),classConstraints,fillPosOfTphs());
// System.out.println("MethodConstraints: " + methodConstraints); // System.out.println("MethodConstraints: " + methodConstraints);

View File

@ -51,8 +51,8 @@ public class TestExample42_allInOneMethod {
@Test @Test
public void genericTest() { public void genericTest() {
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs()); // List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs());
System.out.println("ClassConstraints: " + classConstraints); // System.out.println("ClassConstraints: " + classConstraints);
// List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),classConstraints,fillPosOfTphs(),); // List<MethodConstraint> methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),classConstraints,fillPosOfTphs(),);
// System.out.println("MethodConstraints: " + methodConstraints); // System.out.println("MethodConstraints: " + methodConstraints);