eclipse-ee4j / eclipse-ee4j/yasson
Map deserialization doesn't use Adapter and generates runtime exception on access
- Dominant language
- Java
- Stars
- 218
- Forks
- 109
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 9
Description
Given a simple POJO "Person" with a String attribute "name" and a test like
` public static void main(String[] args) {
String json = "{\"foo\" : \"bar\"}";
Map map = JsonbBuilder.create().fromJson(json, new HashMap() {}.getClass().getGenericSuperclass());
map.keySet().forEach(Person::getName);
}
`
I end up with
`Exception in thread "main" java.lang.ClassCastException: java.lang.String cannot be cast to test.Person
at java.util.HashMap$KeySet.forEach(HashMap.java:933)
at test.Test.main(Test.java:14)`
If I register an adapter for Person, it is never called. How can a String even fit into the Person map key and only be detected at runtime?
Contributor guide
Assessment
This issue has not been assessed yet.