jakartaee / jakartaee/jsonb-api
JsonbTypeAdapter missing ElementType.PARAMETER
- Dominant language
- Java
- Stars
- 95
- Forks
- 41
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 35
Description
It does not appear `JsonbTypeAdapter` can be used everywhere `JsonbProperty` can be used.
Imagine we have this field-based class
```
public class Source {
@JsonbProperty("className")
private String className;
@JsonbProperty("path")
@JsonbTypeAdapter(FileAdapter.class)
private File path;
@JsonbProperty("packageName")
private String packageName;
@JsonbProperty("imports")
private List imports;
//...
```
We decide that we instead want to have final variables and use a constructor via `JsonbCreator` as such:
```
public class Source {
private final String className;
private final File path;
private final String packageName;
private final List imports;
@JsonbCreator
public Source(@JsonbProperty("className") final String className,
@JsonbProperty("path") final File path,
@JsonbProperty("packageName") final String packageName,
@JsonbProperty("imports") final List imports) {
this.className = className;
this.path = path;
this.packageName = packageName;
this.imports = imports;
}
//...
```
The limitation that prevents this from working appears to be that `@JsonbTypeAdapter` cannot "follow" the other annotations and be placed on the appropriate constructor parameter.
Contributor guide
Research direction
Start by inspecting the JsonbTypeAdapter declaration and the related JsonbProperty and JsonbCreator annotation metadata. Check how constructor parameters are handled, then verify that the adapter can be applied in the same constructor-parameter scenario described in the issue without breaking field-based usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100