From 68034ed4349aae557ca43513c18649dbee0d8c39 Mon Sep 17 00:00:00 2001 From: Victorious3 Date: Thu, 23 Feb 2023 18:52:29 +0100 Subject: [PATCH] Fix FunNGenerator --- .../java/de/dhbwstuttgart/bytecode/FunNGenerator.java | 8 +++++--- src/test/resources/target/Test.java | 9 --------- 2 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 src/test/resources/target/Test.java diff --git a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java index c5ae16f7..49c9b736 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java @@ -31,7 +31,7 @@ public class FunNGenerator { private static String applyDescriptor(TargetType a) { return a.toDescriptor(); } private static String applySignature(TargetType a) { return a.toSignature(); } - private static String applyNameDescriptor(TargetType a){ return a instanceof TargetGenericType ? "LTPH;" : String.format("L%s;", applySignature(a)); } + private static String applyNameDescriptor(TargetType a){ return a instanceof TargetGenericType ? "LTPH;" : String.format("%s;", applySignature(a)); } public static byte[] generateSuperBytecode(int numberArguments) { StringBuilder superFunNClassSignature = new StringBuilder("<"); @@ -40,13 +40,15 @@ public class FunNGenerator { for (int currentParameter = 1; currentParameter <= numberArguments; currentParameter++){ superFunNClassSignature.append(String.format("%s%d:%s",argumentGenericBase, currentParameter, objectSignature)); - superFunNMethodSignature.append(String.format("T%s;", applySignature(new TargetRefType(argumentGenericBase + currentParameter)))); + superFunNMethodSignature.append(String.format("%s", applySignature(new TargetRefType(argumentGenericBase + currentParameter)))); superFunNMethodDescriptor.append(objectSignature); } superFunNClassSignature.append(String.format("%s:%s>%s", returnGeneric, objectSignature, objectSignature)); - superFunNMethodSignature.append(String.format(")T%s;", applySignature(new TargetRefType(returnGeneric)))); + superFunNMethodSignature.append(String.format(")%s", applySignature(new TargetRefType(returnGeneric)))); superFunNMethodDescriptor.append(String.format(")%s", objectSignature)); + System.out.println(superFunNMethodSignature); + ClassWriter classWriter = new ClassWriter(0); MethodVisitor methodVisitor; classWriter.visit(bytecodeVersion, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, getSuperClassName(numberArguments), superFunNClassSignature.toString(), objectSuperType, null); diff --git a/src/test/resources/target/Test.java b/src/test/resources/target/Test.java deleted file mode 100644 index f7e1a0bc..00000000 --- a/src/test/resources/target/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -public class Test { - public void lambda() { - Interface mul2 = (Integer a) -> a * 2; - } -} - -interface Interface { - R apply(T t); -} \ No newline at end of file