File tree Expand file tree Collapse file tree 3 files changed +59
-1
lines changed
main/java/com/code_intelligence/jazzer/mutation/mutator/aggregate
test/java/com/code_intelligence/jazzer/mutation/mutator Expand file tree Collapse file tree 3 files changed +59
-1
lines changed Original file line number Diff line number Diff line change 1818
1919import static com .code_intelligence .jazzer .mutation .mutator .aggregate .AggregatesHelper .asInstantiationFunction ;
2020import static com .code_intelligence .jazzer .mutation .mutator .aggregate .BeanSupport .findConstructorsByParameterCount ;
21+ import static com .code_intelligence .jazzer .mutation .mutator .aggregate .BeanSupport .resolveAnnotatedParameterTypes ;
2122import static com .code_intelligence .jazzer .mutation .support .StreamSupport .findFirstPresent ;
2223import static com .code_intelligence .jazzer .mutation .support .TypeSupport .asSubclassOrEmpty ;
2324
@@ -63,7 +64,7 @@ private static Optional<SerializingMutator<?>> buildMutator(
6364 return AggregatesHelper .createMutator (
6465 factory ,
6566 constructor .getDeclaringClass (),
66- constructor . getAnnotatedParameterTypes ( ),
67+ resolveAnnotatedParameterTypes ( constructor , initialType ),
6768 fromParametersToObject ,
6869 fromObjectToParameters ,
6970 initialType ,
Original file line number Diff line number Diff line change @@ -492,6 +492,27 @@ public String toString() {
492492 }
493493 }
494494
495+ public static class GenericOnlyConstructorBean <T > {
496+ private final T t ;
497+
498+ GenericOnlyConstructorBean (T t ) {
499+ this .t = t ;
500+ }
501+
502+ @ Override
503+ public boolean equals (Object o ) {
504+ if (this == o ) return true ;
505+ if (o == null || getClass () != o .getClass ()) return false ;
506+ GenericOnlyConstructorBean <T > that = (GenericOnlyConstructorBean <T >) o ;
507+ return Objects .equals (t , that .t );
508+ }
509+
510+ @ Override
511+ public int hashCode () {
512+ return Objects .hash (t );
513+ }
514+ }
515+
495516 public static class SuperBuilderTarget {
496517 private final String foo ;
497518
@@ -971,6 +992,12 @@ void singleParam(int parameter) {}
971992 false ,
972993 manyDistinctElements (),
973994 manyDistinctElements ()),
995+ arguments (
996+ new TypeHolder <@ NotNull GenericOnlyConstructorBean <String >>() {}.annotatedType (),
997+ "[Nullable<String>] -> GenericOnlyConstructorBean" ,
998+ false ,
999+ manyDistinctElements (),
1000+ manyDistinctElements ()),
9741001 arguments (
9751002 new TypeHolder <@ NotNull List <OnlyConstructorBean >>() {}.annotatedType (),
9761003 "List<Nullable<[Nullable<String>, Nullable<List<Nullable<Integer>>>, Boolean] ->"
Original file line number Diff line number Diff line change @@ -192,4 +192,34 @@ void testEmptyArgsConstructor() throws IOException {
192192 EmptyArgs read = mutator .readExclusive (new ByteArrayInputStream (new byte [] {}));
193193 mutator .writeExclusive (read , new ByteArrayOutputStream ());
194194 }
195+
196+ static class GenericClass <T > {
197+ private final T t ;
198+
199+ GenericClass (T t ) {
200+ this .t = t ;
201+ }
202+
203+ @ Override
204+ public boolean equals (Object o ) {
205+ if (this == o ) return true ;
206+ if (o == null || getClass () != o .getClass ()) return false ;
207+ GenericClass <T > that = (GenericClass <T >) o ;
208+ return Objects .equals (t , that .t );
209+ }
210+
211+ @ Override
212+ public int hashCode () {
213+ return Objects .hash (t );
214+ }
215+ }
216+
217+ @ Test
218+ void testGenericClass () {
219+ SerializingMutator <GenericClass <String >> mutator =
220+ (SerializingMutator <GenericClass <String >>)
221+ Mutators .newFactory ()
222+ .createOrThrow (new TypeHolder <GenericClass <String >>() {}.annotatedType ());
223+ assertThat (mutator .toString ()).startsWith ("Nullable<[Nullable<String>] -> GenericClass>" );
224+ }
195225}
You can’t perform that action at this time.
0 commit comments