Fix FunNGenerator

This commit is contained in:
Victorious3 2023-02-23 18:52:29 +01:00
parent a92172c9da
commit 68034ed434
2 changed files with 5 additions and 12 deletions

View File

@ -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);

View File

@ -1,9 +0,0 @@
public class Test {
public void lambda() {
Interface<Integer, Integer> mul2 = (Integer a) -> a * 2;
}
}
interface Interface<R, T> {
R apply(T t);
}