gwt-jackson
gwt-jackson copied to clipboard
Annotations on Java8 default interface are ignored
The following code will work as expected with the real Jackson library but it will fail will gwt-jackson.
public static interface InterfaceBean {
@JsonIgnore
default String getName(){
return "defaultName";
}
}
Find attached a branch to reproduce the issue: https://github.com/freddyboucher/gwt-jackson/commit/6ac68d28a3314e65733453034112d22d55841742
I also opened this GWT thread: https://groups.google.com/forum/#!topic/google-web-toolkit/JqHMFcrHKDI
As of latest GWT 2.8.2, we cannot fix this issue because default methods are not exposed in Generator.
I'm quoting Thomas Broyer
This is a known (and on-purpose) limitation; see https://github.com/gwtproject/gwt/issues/9371 (tl;dr: exposing the method like any other would have been a breaking change for all existing generators, which would have wanted to implement the method, unless they are updated to recognize them as default methods; and for static methods it would have really broken many generators which would have tried to override the static method!). Because we want to encourage migration of generators to annotation processors, there was no pressing need to support it in generators; so generators (and users of generators!) cannot take advantage of static or default methods on interfaces.