From d93836d1105faedf7549c99cfc16e2c4b56f2e2f Mon Sep 17 00:00:00 2001 From: Victorious3 Date: Tue, 21 Mar 2023 12:12:42 +0100 Subject: [PATCH] Fix incorrect generics for derived FunN --- Test.java | 7 +++++++ src/main/java/de/dhbwstuttgart/bytecode/Codegen.java | 2 ++ src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java | 6 +++--- src/test/java/targetast/TestComplete.java | 1 - 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 Test.java diff --git a/Test.java b/Test.java new file mode 100644 index 000000000..b0e1ed48e --- /dev/null +++ b/Test.java @@ -0,0 +1,7 @@ +public interface Test extends Base { + +} + +interface Base { + +} diff --git a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java index df56b333f..efa8def22 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java @@ -1025,6 +1025,8 @@ public class Codegen { if (!method.txGenerics().isEmpty()) mv.visitAttribute(new JavaTXSignatureAttribute(method.getTXSignature())); + System.out.println(method.getDescriptor()); + System.out.println(method.getSignature()); mv.visitCode(); var state = new State(method.returnType(), mv, method.isStatic() ? 0 : 1); for (var param: method.parameters()) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java index ad032c022..270a0bb52 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.bytecode; +import de.dhbwstuttgart.target.tree.TargetGeneric; import de.dhbwstuttgart.target.tree.type.TargetGenericType; import de.dhbwstuttgart.target.tree.type.TargetRefType; import de.dhbwstuttgart.target.tree.type.TargetType; @@ -66,7 +67,7 @@ public class FunNGenerator { List parameters = Stream .concat(argumentTypes.stream(), Stream.of(returnType)) .collect(Collectors.toList()); - StringBuilder funNClassSignature = new StringBuilder(objectSignature + applySignature(new TargetRefType(getSuperClassName(argumentTypes.size()), parameters))); + StringBuilder funNClassSignature = new StringBuilder(objectSignature + applyDescriptor(new TargetRefType(getSuperClassName(argumentTypes.size()), parameters))); boolean containsGeneric = false; String genericSignature = "<"; @@ -74,13 +75,12 @@ public class FunNGenerator { //ToDo Etienne: Refactor if (typeArgument instanceof TargetGenericType generic){ //if(genericSignature.contains(generic.name())) continue; - genericSignature += String.format("%s:%s", generic.name(), applyDescriptor(generic)); + genericSignature += String.format("%s:%s", generic.name(), objectSignature); containsGeneric = true; } } genericSignature += ">"; if (containsGeneric) funNClassSignature.insert(0, genericSignature); - System.out.println(funNClassSignature.toString()); ClassWriter classWriter = new ClassWriter(0); classWriter.visit(bytecodeVersion, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, getSpecializedClassName(argumentTypes, returnType), funNClassSignature.toString(), objectSuperType, new String[]{getSuperClassName(argumentTypes.size())}); diff --git a/src/test/java/targetast/TestComplete.java b/src/test/java/targetast/TestComplete.java index 5333944e0..b1773e150 100644 --- a/src/test/java/targetast/TestComplete.java +++ b/src/test/java/targetast/TestComplete.java @@ -233,7 +233,6 @@ public class TestComplete { } @Test - @Ignore public void matrixTest() throws Exception { var classFiles = generateClassFiles("Matrix.jav", new ByteArrayClassLoader()); var matrix = classFiles.get("Matrix");