Wednesday, October 2, 2019

Annotations on Java8 default are not available in Generator


I'm a user of the gwt-jackson library and I've just found the following bug:

To fix it, I need to get access of the annotations on a default Java8 method interface:

    public static interface InterfaceBean {
default String getName(){
return "defaultName";

But tell me if I'm wrong, GWT doesn't provide this information!
I did setup a minimal demo project to explain the issue:

As you see the default `getGender` method is not listed in neither HasGender or Person JClassType

public interface HasGender {
default String getGender() {
return "male";

public class Person implements HasGender {
public String getName() {
return "Paul";

public class CustomGenerator extends Generator {

public final String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
JClassType genderType = context.getTypeOracle().findType(HasGender.class.getName());
assert genderType.getMethods().length == 0;
assert genderType.getInheritableMethods().length == 0;
assert genderType.getOverridableMethods().length == 0;

JClassType personType = context.getTypeOracle().findType(Person.class.getName());
assert Arrays.equals(new String[] { "getName" },;
assert personType.getMethods()[0].isAnnotationPresent(Nonnull.class);

String[] common = { "equals", "finalize", "getClass", "getName", "hashCode", "toString" };
assert Arrays.equals(common,;
assert Arrays.equals(common,;
return null;


You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment