-
Type: Bug
-
Resolution: Unresolved
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: POJO
-
None
-
Java Drivers
Summary
ClassModel.builder has a problem when a class contains fields that have nested parametrized types. The only solution I found was to loose the types, e.g by using raw types or avoid extends.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
Tested on 4.8.2, 5.1.4, 5.2.0
How to Reproduce
package org.example; import java.util.List; import org.bson.codecs.pojo.ClassModel; class Counter<T extends Number> {} class Person<T extends Counter<?>> { public T counter; } class Pojo1 { public List<? extends Person<? extends Counter<?>>> persons; } class Pojo2 { public List<Person<? extends Counter<?>>> persons; } class Pojo3 { public List<Person<?>> persons; } class Pojo4 { public List<Person<? extends Counter>> persons; } class Pojo5 { public List<? extends Person> persons; } class Pojo6 { public List<? extends Person<?>> persons; } public class Main { public static void main(String[] args) { ClassModel.builder(Pojo1.class); // throws ClassModel.builder(Pojo2.class); // throws ClassModel.builder(Pojo3.class); // ok ClassModel.builder(Pojo4.class); // ok ClassModel.builder(Pojo5.class); // ok ClassModel.builder(Pojo6.class); // throws } }
- related to
-
JAVA-3853 Refactor Pojo Codec
- Backlog