繁体   English   中英

GWT继承接口的类生成器

[英]GWT Classes generator of inherited interface

我有界面A:

public interface A{
     String someMethod();
}

使用GWT.create(A.class),我可以立即实现这个接口。

但是如果我创建接口B();

public interface B extends A{
     String someOtherMethod();
}

并且做GWT.create(B.class)我得到B接口的实现,但没有实现A接口方法。

并获得编译错误:

[错误]第3行:类型B_impl必须实现抽象方法A.someMethod()

附加:正如我后来发现的,可能是它与Annotations有关。

所以我有:

public interface annotationHelperClass{
}

具有:

public final class annotationHelperClassGenerator{
//Some code
}

注解:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MyAnnotation {
    String someParam();
}

所以接口A将是:

public interface A extends annotationHelperClass{
         @MyAnnotation(someParam = "Some string")
         String someMethod();
    }

界面B:

public interface B extends A{
         @MyAnnotation(someParam = "Some another string")
         String someOtherMethod();
    }

问题是我的发电机使用:

for (JMethod method : targetClass.getMethods()) {
    MyAnnotation descriptor = method.getAnnotation(MyAnnotation.class);
        JParameter[] parameters = method.getParameters();
        //some code
}

因此,在getInheritableMethods()上更改getMethods()可以解决此问题。

很抱歉没有详细说明,我不确定在这种情况下重要的是什么!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM