diff --git a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java index ee6047791..70810cbd6 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java @@ -979,7 +979,7 @@ public class Codegen { } private void generateConstructor(TargetConstructor constructor) { - MethodVisitor mv = cw.visitMethod(constructor.access() | ACC_PUBLIC, "", constructor.getDescriptor(), null, null); + MethodVisitor mv = cw.visitMethod(constructor.access() | ACC_PUBLIC, "", constructor.getDescriptor(), constructor.getSignature(), null); mv.visitCode(); var state = new State(null, mv, 1); for (var param: constructor.parameters()) @@ -1028,7 +1028,7 @@ public class Codegen { public byte[] generate() { cw.visit(V1_8, clazz.modifiers() | ACC_PUBLIC | ACC_SUPER, clazz.qualifiedName(), - null, clazz.superType() != null ? clazz.superType().getInternalName(): "java/lang/Object", + generateSignature(clazz), clazz.superType() != null ? clazz.superType().getInternalName(): "java/lang/Object", clazz.implementingInterfaces().stream().map(TargetType::toSignature).toArray(String[]::new) ); clazz.fields().forEach(this::generateField); diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index a421a0878..28b059c8b 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -135,7 +135,7 @@ public class ASTToTargetAST { typeVariablesOfFields.addAll(findTypeVariables(field.getType())); } - //findTypeVariables(method.getReturnType(), typeVariables); + typeVariables.addAll(findTypeVariables(method.getReturnType())); for (var arg : method.getParameterList().getFormalparalist()) { typeVariables.addAll(findTypeVariables(arg.getType())); } @@ -459,7 +459,6 @@ public class ASTToTargetAST { addToPairs(result, new PairTPHequalRefTypeOrWildcardType(pair.right, OBJECT)); } } - eliminateCyclesAndInfima(result); usedTPHsOfMethods.put(method, typeVariables); @@ -471,7 +470,7 @@ public class ASTToTargetAST { } typeVariablesOfSignature.addAll(findTypeVariables(method.getReturnType())); - eliminateInnerTypeVariables(typeVariablesOfSignature, result); + //eliminateInnerTypeVariables(typeVariablesOfSignature, result); System.out.println(method.name + ": " + result); return result; diff --git a/src/test/java/targetast/TestGenerics.java b/src/test/java/targetast/TestGenerics.java index 8dea939b7..1131e076a 100644 --- a/src/test/java/targetast/TestGenerics.java +++ b/src/test/java/targetast/TestGenerics.java @@ -226,7 +226,6 @@ public class TestGenerics { } @Test - @Ignore("This doesn't work properly") public void testThreeArgs() throws Exception { var result = computeGenerics("TestThreeArgs.jav"); }