diff --git a/resources/bytecode/javFiles/Bug293.jav b/resources/bytecode/javFiles/Bug293.jav new file mode 100644 index 00000000..0e7dc265 --- /dev/null +++ b/resources/bytecode/javFiles/Bug293.jav @@ -0,0 +1,13 @@ +import java.lang.Integer; +import java.lang.Float; + +public class Bug293 { + bar(a) { + return 2 * a; + } +} + +interface IFoo { + void ga(); +} + diff --git a/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java b/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java index ae942496..403ccdb8 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/GenerateGenerics.java @@ -753,7 +753,9 @@ public abstract class GenerateGenerics { } doIterationForMethods(classOrInterface); for (var method : classOrInterface.getMethods()) { - referenced.addAll(usedTPHsOfMethods.get(method)); + var usedTPHs = usedTPHsOfMethods.get(method); + if (usedTPHs != null) + referenced.addAll(usedTPHs); } eliminateInnerTypeVariables(referenced, input); } diff --git a/src/test/java/TestComplete.java b/src/test/java/TestComplete.java index 4d1fbc94..f675128c 100644 --- a/src/test/java/TestComplete.java +++ b/src/test/java/TestComplete.java @@ -933,4 +933,11 @@ public class TestComplete { var clazz = classFiles.get("Bug290A"); var instance = clazz.getDeclaredConstructor().newInstance(); } + + @Test + public void testBug293() throws Exception { + var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug293.jav"); + var clazz = classFiles.get("Bug293"); + var instance = clazz.getDeclaredConstructor().newInstance(); + } }