File tree Expand file tree Collapse file tree
main/java/com/code_intelligence/jazzer/mutation/mutator/aggregate
test/java/com/code_intelligence/jazzer/mutation/mutator Expand file tree Collapse file tree 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
@@ -977,6 +998,12 @@ void singleParam(int parameter) {}
977998 false ,
978999 manyDistinctElements (),
9791000 manyDistinctElements ()),
1001+ arguments (
1002+ new TypeHolder <@ NotNull GenericOnlyConstructorBean <String >>() {}.annotatedType (),
1003+ "[Nullable<String>] -> GenericOnlyConstructorBean" ,
1004+ false ,
1005+ manyDistinctElements (),
1006+ manyDistinctElements ()),
9801007 arguments (
9811008 new TypeHolder <@ NotNull List <OnlyConstructorBean >>() {}.annotatedType (),
9821009 "List<Nullable<[Nullable<String>, Nullable<List<Nullable<Integer>>>, Boolean] ->"
Original file line number Diff line number Diff line change @@ -192,4 +192,21 @@ 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+
204+ @ Test
205+ void testGenericClass () {
206+ SerializingMutator <GenericClass <String >> mutator =
207+ (SerializingMutator <GenericClass <String >>)
208+ Mutators .newFactory ()
209+ .createOrThrow (new TypeHolder <GenericClass <String >>() {}.annotatedType ());
210+ assertThat (mutator .toString ()).startsWith ("Nullable<[Nullable<String>] -> GenericClass>" );
211+ }
195212}
You can’t perform that action at this time.
0 commit comments