Verbesserung des spezialisierten Namens von FunN$$.

Nun steht zwischen $$ und den Attributen ein $_$, welches zuvor vergessen wurde.
This commit is contained in:
Etienne Zink 2022-05-22 12:18:10 +02:00
parent 5071406b3f
commit 669c778af8
No known key found for this signature in database
GPG Key ID: CF63B6867873957B
4 changed files with 25 additions and 25 deletions

View File

@ -113,7 +113,7 @@ public final class FunNGenerator implements FunNUtilities{
public String getSpecializedClassName(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) { public String getSpecializedClassName(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
Objects.requireNonNull(argumentTypes); Objects.requireNonNull(argumentTypes);
Objects.requireNonNull(returnType); Objects.requireNonNull(returnType);
return String.format("Fun%d$$%s%s", return String.format("Fun%d$$$_$%s%s",
argumentTypes.size(), argumentTypes.size(),
argumentTypes argumentTypes
.stream() .stream()

View File

@ -38,10 +38,10 @@ public class OLFun2Test {
compiler.generateBytecode(generatedByteCodeDirectory); compiler.generateBytecode(generatedByteCodeDirectory);
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)}); loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
classToTest = loader.loadClass("OLFun2"); classToTest = loader.loadClass("OLFun2");
classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$"); classFun1IntInt = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$"); classFun1IntDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$"); classFun1DoubleDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Double$_$");
classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$"); classFun1DoubleInt = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
} }
@Test @Test

View File

@ -40,12 +40,12 @@ public class OLFunTest {
compiler.generateBytecode(generatedByteCodeDirectory); compiler.generateBytecode(generatedByteCodeDirectory);
loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)}); loader = new URLClassLoader(new URL[] {new URL("file://"+generatedByteCodeDirectory)});
classToTest = loader.loadClass("OLFun"); classToTest = loader.loadClass("OLFun");
classFun1IntInt = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Integer$_$"); classFun1IntInt = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$");
classFun1IntDouble = loader.loadClass("Fun1$$Ljava$lang$Integer$_$Ljava$lang$Double$_$"); classFun1IntDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Integer$_$Ljava$lang$Double$_$");
classFun1DoubleDouble = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Double$_$"); classFun1DoubleDouble = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Double$_$");
classFun1DoubleInt = loader.loadClass("Fun1$$Ljava$lang$Double$_$Ljava$lang$Integer$_$"); classFun1DoubleInt = loader.loadClass("Fun1$$$_$Ljava$lang$Double$_$Ljava$lang$Integer$_$");
classFun1StringInt = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Integer$_$"); classFun1StringInt = loader.loadClass("Fun1$$$_$Ljava$lang$String$_$Ljava$lang$Integer$_$");
classFun1StringDouble = loader.loadClass("Fun1$$Ljava$lang$String$_$Ljava$lang$Double$_$"); classFun1StringDouble = loader.loadClass("Fun1$$$_$Ljava$lang$String$_$Ljava$lang$Double$_$");
} }
@Test @Test

View File

@ -49,70 +49,70 @@ public class FunNGeneratorTest {
@Test @Test
public void specializedClassName_VoidVoid(){ public void specializedClassName_VoidVoid(){
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), voidType); var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), voidType);
assertEquals("Fun0$$Ljava$lang$Void$_$", specializedClassName); assertEquals("Fun0$$$_$Ljava$lang$Void$_$", specializedClassName);
} }
@Test @Test
public void specializedClassName_VoidInt(){ public void specializedClassName_VoidInt(){
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), integerType); var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(), integerType);
assertEquals("Fun0$$Ljava$lang$Integer$_$", specializedClassName); assertEquals("Fun0$$$_$Ljava$lang$Integer$_$", specializedClassName);
} }
@Test @Test
public void specializedClassName_IntInt(){ public void specializedClassName_IntInt(){
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), integerType); 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 @Test
public void specializedClassName_IntT(){ public void specializedClassName_IntT(){
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), genericT); var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), genericT);
assertEquals("Fun1$$Ljava$lang$Integer$_$LT$_$", specializedClassName); assertEquals("Fun1$$$_$Ljava$lang$Integer$_$LT$_$", specializedClassName);
} }
@Test @Test
public void specializedClassName_IntTPH(){ public void specializedClassName_IntTPH(){
var specializedClassName = funNGenerator.getSpecializedClassName(Arrays.asList(integerType), TypePlaceholder.fresh(null)); 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 @Test
public void signature_IntInt(){ public void signature_IntInt(){
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), integerType); 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 @Test
public void signature_IntT(){ public void signature_IntT(){
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), genericT); var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(integerType), genericT);
assertEquals("LFun1$$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature); assertEquals("LFun1$$$_$Ljava$lang$Integer$_$LT$_$<TT;>;", classSignature);
} }
@Test @Test
public void signature_TPHTPH(){ public void signature_TPHTPH(){
var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph); var classSignature = funNGenerator.getSpecializedSignature(Arrays.asList(tph), tph);
assertEquals(String.format("LFun1$$LTPH$_$LTPH$_$<T%s$;T%s$;>;",tph.getName(), tph.getName()), classSignature); assertEquals(String.format("LFun1$$$_$LTPH$_$LTPH$_$<T%s$;T%s$;>;",tph.getName(), tph.getName()), classSignature);
} }
@Test @Test
public void descriptor_IntInt(){ public void descriptor_IntInt(){
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), integerType); 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 //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 @Test
public void descriptor_IntT(){ public void descriptor_IntT(){
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(integerType), genericT); 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 //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 @Test
public void descriptor_TPHTPH(){ public void descriptor_TPHTPH(){
var classDescriptor = funNGenerator.getSpecializedDescriptor(Arrays.asList(tph), tph); 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 //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 @Test
@ -227,21 +227,21 @@ public class FunNGeneratorTest {
//specialized bytecode reference methods //specialized bytecode reference methods
private static byte[] specializedBytecodeReference_VoidInt() { private static byte[] specializedBytecodeReference_VoidInt() {
ClassWriter classWriter = new ClassWriter(0); ClassWriter classWriter = new ClassWriter(0);
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$<Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun0$$"}); classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun0$$$_$Ljava$lang$Integer$_$", "Ljava/lang/Object;LFun0$$<Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun0$$"});
classWriter.visitEnd(); classWriter.visitEnd();
return classWriter.toByteArray(); return classWriter.toByteArray();
} }
private static byte[] specializedBytecodeReference_IntInt() { private static byte[] specializedBytecodeReference_IntInt() {
ClassWriter classWriter = new ClassWriter(0); 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$$<Ljava/lang/Integer;Ljava/lang/Integer;>;", "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$$<Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun1$$"});
classWriter.visitEnd(); classWriter.visitEnd();
return classWriter.toByteArray(); return classWriter.toByteArray();
} }
private static byte[] specializedBytecodeReference_TIntInt() { private static byte[] specializedBytecodeReference_TIntInt() {
ClassWriter classWriter = new ClassWriter(0); ClassWriter classWriter = new ClassWriter(0);
classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "<T:Ljava/lang/Object;>Ljava/lang/Object;LFun2$$<TT;Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun2$$"}); classWriter.visit(V1_8, ACC_PUBLIC | ACC_ABSTRACT | ACC_INTERFACE, "Fun2$$$_$LT$_$Ljava$lang$Integer$_$Ljava$lang$Integer$_$", "<T:Ljava/lang/Object;>Ljava/lang/Object;LFun2$$<TT;Ljava/lang/Integer;Ljava/lang/Integer;>;", "java/lang/Object", new String[]{"Fun2$$"});
classWriter.visitEnd(); classWriter.visitEnd();
return classWriter.toByteArray(); return classWriter.toByteArray();
} }