From 0207c7d1b0f57da02be6fadd1b6c217928bbadc1 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Sun, 20 Mar 2022 16:59:24 +0100 Subject: [PATCH] =?UTF-8?q?Verbesserung=20typParameter=20von=20Intermediat?= =?UTF-8?q?eRefType:=20K=C3=B6nnen=20IntermediateInnerType=20sein!=20Nicht?= =?UTF-8?q?=20nur=20IntermediateRefType=20wie=20zuvor.=20Hizuf=C3=BCgen=20?= =?UTF-8?q?entsprechender=20Tests.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intermediate/types/IntermediateRefType.java | 4 ++-- .../types/IntermediateGenericTypeTest.java | 9 +++++++-- .../types/IntermediateRefTypeTest.java | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java index 81ef371a..d82bbb71 100644 --- a/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java +++ b/src/main/java/de/dhbwstuttgart/intermediate/types/IntermediateRefType.java @@ -13,7 +13,7 @@ import java.util.List; */ public final class IntermediateRefType extends IntermediateInnerType{ - private final List typParameters; + private final List typParameters; private final JavaClassName className; /** @@ -35,7 +35,7 @@ public final class IntermediateRefType extends IntermediateInnerType{ this(className, new ArrayList<>()); } - public IntermediateRefType(JavaClassName className, List typParameters){ + public IntermediateRefType(JavaClassName className, List typParameters){ this.className = className; this.typParameters = Collections.unmodifiableList(typParameters); } diff --git a/src/test/java/intermediate/types/IntermediateGenericTypeTest.java b/src/test/java/intermediate/types/IntermediateGenericTypeTest.java index 3c711c4e..5ab67f3e 100644 --- a/src/test/java/intermediate/types/IntermediateGenericTypeTest.java +++ b/src/test/java/intermediate/types/IntermediateGenericTypeTest.java @@ -7,6 +7,10 @@ import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -33,9 +37,10 @@ public class IntermediateGenericTypeTest { t = new IntermediateGenericType("T"); sExtendsStringSignature = "TS;"; - sExtendsStringDescriptor = "Ljava/lang/String;"; + sExtendsStringDescriptor = "Ljava/util/List;"; sExtendsString = new IntermediateGenericType("S", - new IntermediateRefType(new JavaClassName(Type.getInternalName(String.class)))); + new IntermediateRefType(new JavaClassName(Type.getInternalName(List.class)), + Arrays.asList(new IntermediateRefType(new JavaClassName(Type.getInternalName(Integer.class)))))); rExtendsSSignature = "TR;"; rExtendsSDescriptor = sExtendsStringDescriptor; diff --git a/src/test/java/intermediate/types/IntermediateRefTypeTest.java b/src/test/java/intermediate/types/IntermediateRefTypeTest.java index bc287a78..fdcca7e2 100644 --- a/src/test/java/intermediate/types/IntermediateRefTypeTest.java +++ b/src/test/java/intermediate/types/IntermediateRefTypeTest.java @@ -1,5 +1,6 @@ package intermediate.types; +import de.dhbwstuttgart.intermediate.types.IntermediateGenericType; import de.dhbwstuttgart.intermediate.types.IntermediateRefType; import de.dhbwstuttgart.parser.scope.JavaClassName; @@ -23,6 +24,10 @@ public class IntermediateRefTypeTest { private static String listOfIntegerDescriptor; private static IntermediateRefType typeToTest_ListOfInteger; + private static String listOfTSignature; + private static String listOfTDescriptor; + private static IntermediateRefType typeToTest_ListOfT; + private static String voidSignature; private static String voidDescriptor; private static IntermediateRefType typeToTest_void; @@ -41,6 +46,12 @@ public class IntermediateRefTypeTest { new JavaClassName(Type.getInternalName(List.class)), Arrays.asList(typeToTest_Integer)); + listOfTSignature = "Ljava/util/List;"; + listOfTDescriptor = "Ljava/util/List;"; + typeToTest_ListOfT = new IntermediateRefType( + new JavaClassName(Type.getInternalName(List.class)), + Arrays.asList(new IntermediateGenericType("T"))); + voidSignature = "V"; voidDescriptor = "V"; typeToTest_void = new IntermediateRefType(new JavaClassName("void")); @@ -66,6 +77,12 @@ public class IntermediateRefTypeTest { @Test public void DescriptorTest_List(){ assertEquals(listOfIntegerDescriptor, typeToTest_ListOfInteger.getDescriptor()); } + @Test + public void SignatureTest_ListT(){ assertEquals(listOfTSignature, typeToTest_ListOfT.getSignature()); } + + @Test + public void DescriptorTest_ListT(){ assertEquals(listOfTDescriptor, typeToTest_ListOfT.getDescriptor()); } + @Test public void SignatureTest_Void(){ assertEquals(voidSignature, typeToTest_void.getSignature());