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

This commit is contained in:
AluAli 2021-03-26 12:30:13 +01:00
commit a4c38b2bb0
8 changed files with 69 additions and 44 deletions

View File

@ -58,7 +58,9 @@ public class TPHConstraint {
public boolean equals (Object o) {
if (o instanceof TPHConstraint) {
TPHConstraint o_tphcons = (TPHConstraint)o;
return (left+right).equals(o_tphcons.getLeft()+o_tphcons.getRight());
return (this.left.equals(o_tphcons.getLeft())
&& this.right.equals(o_tphcons.getRight())
&& this.rel.equals(o_tphcons.rel));
}
else {
return false;

View File

@ -56,16 +56,16 @@ public class TestGGFinder {
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
classConstraintsTest.add(new ClassConstraint("S", "java/lang/Object", Relation.EXTENDS));
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
lmc.add(new MethodConstraint("P", "AC", Relation.EXTENDS));
lmc.add(new MethodConstraint("AC", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ACid(TPH P)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("T", "S", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH SsetA(TPH T)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AC", "Y", Relation.EXTENDS));
lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS));
lmc.add(new MethodConstraint("P", "AC", Relation.EXTENDS));
@ -78,7 +78,10 @@ public class TestGGFinder {
assertEquals(expectedClassCons, computedClassCons);
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
HashMap<String, Set<MethodConstraint>> 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)});

View File

@ -55,12 +55,12 @@ public class TestLocalVarLambda {
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
FamilyOfGeneratedGenerics fogg = compiler.fogg;
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
if (fogg.allConstraints.contains((new MethodConstraint("O", "ALU", Relation.EXTENDS)))) {
lmc.add(new MethodConstraint("O", "ALU", Relation.EXTENDS));
@ -79,7 +79,10 @@ public class TestLocalVarLambda {
assertEquals(expectedClassCons, computedClassCons);
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
HashMap<String, Set<MethodConstraint>> 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)});

View File

@ -49,18 +49,19 @@ public class TestMutualRecursion {
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
classConstraintsTest.add(new ClassConstraint("N", "java/lang/Object", Relation.EXTENDS));
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
lmc.add(new MethodConstraint("P", "Q", Relation.EXTENDS));
lmc.add(new MethodConstraint("Q", "java/lang/Object", Relation.EXTENDS));
lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ALid(TPH P)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS));
lmc.add(new MethodConstraint("Z", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ALm(TPH ALTPH Z)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AG", "java/lang/Object", Relation.EXTENDS));
lmc.add(new MethodConstraint("AH", "java/lang/Object", Relation.EXTENDS));
lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS));
@ -71,8 +72,11 @@ public class TestMutualRecursion {
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
assertEquals(expectedClassCons, computedClassCons);
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionComputed = new HashMap<>();
fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l)));
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed);
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});

View File

@ -56,12 +56,12 @@ public class TestTPHsAndGenerics {
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
FamilyOfGeneratedGenerics fogg = compiler.fogg;
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
if (fogg.allConstraints.contains((new MethodConstraint("DZP", "ETW", Relation.EXTENDS)))) {
classConstraintsTest.add(new ClassConstraint("UD", "DZP", Relation.EXTENDS));
@ -74,10 +74,10 @@ public class TestTPHsAndGenerics {
lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS));
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("V", "UD", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc);
}
@ -92,10 +92,10 @@ public class TestTPHsAndGenerics {
lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS));
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("V", "ETW", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc);
}
@ -105,7 +105,10 @@ public class TestTPHsAndGenerics {
assertEquals(expectedClassCons, computedClassCons);
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionComputed = new HashMap<>();
fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l)));
assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed);
/*
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);

View File

@ -61,20 +61,20 @@ public class TestTwoArgs {
classConstraintsTest.add(new ClassConstraint("P", "AL", Relation.EXTENDS));
classConstraintsTest.add(new ClassConstraint("AL", "AF", Relation.EXTENDS));
classConstraintsTest.add(new ClassConstraint("AF", "java/lang/Object", Relation.EXTENDS));
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH ALid(TPH P)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AL", "AF", Relation.EXTENDS));
lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS));
lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH AFm(TPH AFTPH Z)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH APsetA(TPH T)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("AG", "P", Relation.EXTENDS));
lmc.add(new MethodConstraint("AH", "T", Relation.EXTENDS));
lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS));
@ -84,9 +84,12 @@ public class TestTwoArgs {
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
assertEquals(expectedClassCons, computedClassCons);
assertEquals(expectedClassCons, computedClassCons);
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionComputed = new HashMap<>();
fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l)));
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed);
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});

View File

@ -55,13 +55,13 @@ public class TestTwoCalls {
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
lmc.add(new MethodConstraint("O", "R", Relation.EXTENDS));
lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH Rid(TPH O)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("T", "O", Relation.EXTENDS));
lmc.add(new MethodConstraint("O", "R", Relation.EXTENDS));
lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS));
@ -73,8 +73,12 @@ public class TestTwoCalls {
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
assertEquals(expectedClassCons, computedClassCons);
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionComputed = new HashMap<>();
fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l)));
assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed);
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass(className);

View File

@ -55,14 +55,14 @@ public class TestVector {
List<GenericGenratorResultForSourceFile> simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results);
List<ClassConstraint> classConstraintsTest = new ArrayList<>();
HashMap<String, List<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
List<MethodConstraint> lmc;
lmc = new ArrayList<>();
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
Set<MethodConstraint> lmc;
lmc = new HashSet<>();
lmc.add(new MethodConstraint("T", "W", Relation.EXTENDS));
lmc.add(new MethodConstraint("W", "ZU", Relation.EXTENDS));
lmc.add(new MethodConstraint("ZU", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("voidm(java/util/Vectorjava/util/Vector)", lmc);
lmc = new ArrayList<>();
lmc = new HashSet<>();
lmc.add(new MethodConstraint("W", "java/lang/Object", Relation.EXTENDS));
methodConstraintsWithPositionTest.put("TPH Wid(TPH W)", lmc);
@ -70,9 +70,12 @@ public class TestVector {
Set<ClassConstraint> computedClassCons = new HashSet<>(fogg.classConstraints);
Set<ClassConstraint> expectedClassCons = new HashSet<>(classConstraintsTest);
assertEquals(expectedClassCons, computedClassCons);
assertEquals(expectedClassCons, computedClassCons);
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionComputed = new HashMap<>();
fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l)));
assertEquals(methodConstraintsWithPositionTest, fogg.methodConstraintsWithPosition);
assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed);
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
classToTest = loader.loadClass(className);