From 669c778af8bf80f89dab1e635595a8e2c047e921 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Sun, 22 May 2022 12:18:10 +0200 Subject: [PATCH] Verbesserung des spezialisierten Namens von FunN$$. Nun steht zwischen $$ und den Attributen ein $_$, welches zuvor vergessen wurde. --- .../bytecode/funN/FunNGenerator.java | 2 +- src/test/java/bytecode/OLFun2Test.java | 8 +++--- src/test/java/bytecode/OLFunTest.java | 12 ++++---- .../java/bytecode/funN/FunNGeneratorTest.java | 28 +++++++++---------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java index 903fe6d9..4e2f28cb 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java @@ -113,7 +113,7 @@ public final class FunNGenerator implements FunNUtilities{ public String getSpecializedClassName(List argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) { Objects.requireNonNull(argumentTypes); Objects.requireNonNull(returnType); - return String.format("Fun%d$$%s%s", + return String.format("Fun%d$$$_$%s%s", argumentTypes.size(), argumentTypes .stream() diff --git a/src/test/java/bytecode/OLFun2Test.java b/src/test/java/bytecode/OLFun2Test.java index cf6a38d3..e74409fd 100644 --- a/src/test/java/bytecode/OLFun2Test.java +++ b/src/test/java/bytecode/OLFun2Test.java @@ -38,10 +38,10 @@ public class OLFun2Test { compiler.generateBytecode(generatedByteCodeDirectory); loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)}); classToTest = loader.loadClass("OLFun2"); - classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$"); - classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$"); - classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$"); - classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$"); + classFun1IntInt = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$"); + classFun1IntDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Double$_$"); + classFun1DoubleDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Double$_$"); + classFun1DoubleInt = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Integer$_$"); } @Test diff --git a/src/test/java/bytecode/OLFunTest.java b/src/test/java/bytecode/OLFunTest.java index 7e280459..e0562d05 100644 --- a/src/test/java/bytecode/OLFunTest.java +++ b/src/test/java/bytecode/OLFunTest.java @@ -40,12 +40,12 @@ public class OLFunTest { compiler.generateBytecode(generatedByteCodeDirectory); loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)}); classToTest = loader.loadClass("OLFun"); - classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$"); - classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$"); - classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$"); - classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$"); - classFun1StringInt = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Integer$_$"); - classFun1StringDouble = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Double$_$"); + classFun1IntInt = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$"); + classFun1IntDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Double$_$"); + classFun1DoubleDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Double$_$"); + classFun1DoubleInt = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Integer$_$"); + classFun1StringInt = loader.loadClass("Fun1$$$_$Ljava$lang$String$_$Ljava$lang$Integer$_$"); + classFun1StringDouble = loader.loadClass("Fun1$$$_$Ljava$lang$String$_$Ljava$lang$Double$_$"); } @Test diff --git a/src/test/java/bytecode/funN/FunNGeneratorTest.java b/src/test/java/bytecode/funN/FunNGeneratorTest.java index f465a0ff..8329612e 100644 --- a/src/test/java/bytecode/funN/FunNGeneratorTest.java +++ b/src/test/java/bytecode/funN/FunNGeneratorTest.java @@ -49,70 +49,70 @@ public class FunNGeneratorTest { @Test public void specializedClassName_VoidVoid(){ var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), voidType); - assertEquals("Fun0$$Ljava$lang$Void$_$", specializedClassName); + assertEquals("Fun0$$$_$Ljava$lang$Void$_$", specializedClassName); } @Test public void specializedClassName_VoidInt(){ var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), integerType); - assertEquals("Fun0$$Ljava$lang$Integer$_$", specializedClassName); + assertEquals("Fun0$$$_$Ljava$lang$Integer$_$", specializedClassName); } @Test public void specializedClassName_IntInt(){ var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), integerType); - assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", specializedClassName); + assertEquals("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", specializedClassName); } @Test public void specializedClassName_IntT(){ var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), genericT); - assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", specializedClassName); + assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LT$_$", specializedClassName); } @Test public void specializedClassName_IntTPH(){ var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), TypePlaceholder.fresh(null)); - assertEquals("Fun1$$Ljava$lang$Integer$_$LTPH$_$", specializedClassName); + assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LTPH$_$", specializedClassName); } @Test public void signature_IntInt(){ var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), integerType); - assertEquals("LFun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$;", classSignature); + assertEquals("LFun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$;", classSignature); } @Test public void signature_IntT(){ var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), genericT); - assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$;", classSignature); + assertEquals("LFun1$$$_$Ljava$lang$Integer$_$LT$_$;", classSignature); } @Test public void signature_TPHTPH(){ var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph); - assertEquals(String.format("LFun1$$LTPH$_$LTPH$_$;",tph.getName(), tph.getName()), classSignature); + assertEquals(String.format("LFun1$$$_$LTPH$_$LTPH$_$;",tph.getName(), tph.getName()), classSignature); } @Test public void descriptor_IntInt(){ var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType); //does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well - assertEquals("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classDescriptor); + assertEquals("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", classDescriptor); } @Test public void descriptor_IntT(){ var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT); //does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well - assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", classDescriptor); + assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LT$_$", classDescriptor); } @Test public void descriptor_TPHTPH(){ var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(tph), tph); //does not have to contain L and ; because TypeToDescriptor returns the descriptor without these characters as well - assertEquals("Fun1$$LTPH$_$LTPH$_$", classDescriptor); + assertEquals("Fun1$$$_$LTPH$_$LTPH$_$", classDescriptor); } @Test @@ -227,21 +227,21 @@ public class FunNGeneratorTest { //specialized bytecode reference methods private static byte[] specializedBytecodeReference_VoidInt() { ClassWriter classWriter = new ClassWriter(0); - classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$;", "java/lang/Object", new String[]{"Fun0$$"}); + classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$;", "java/lang/Object", new String[]{"Fun0$$"}); classWriter.visitEnd(); return classWriter.toByteArray(); } private static byte[] specializedBytecodeReference_IntInt() { ClassWriter classWriter = new ClassWriter(0); - classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun1$$;", "java/lang/Object", new String[]{"Fun1$$"}); + classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun1$$;", "java/lang/Object", new String[]{"Fun1$$"}); classWriter.visitEnd(); return classWriter.toByteArray(); } private static byte[] specializedBytecodeReference_TIntInt() { ClassWriter classWriter = new ClassWriter(0); - classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun2$$;", "java/lang/Object", new String[]{"Fun2$$"}); + classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$$_$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun2$$;", "java/lang/Object", new String[]{"Fun2$$"}); classWriter.visitEnd(); return classWriter.toByteArray(); }