简体   繁体   English

GWT继承接口的类生成器

[英]GWT Classes generator of inherited interface

I have interface A: 我有界面A:

public interface A{
     String someMethod();
}

And using GWT.create(A.class) I get instant of implementation of this interface. 使用GWT.create(A.class),我可以立即实现这个接口。

However if I create interface B(); 但是如果我创建接口B();

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

And do GWT.create(B.class) i get implementation of B interface, but without implementations A interface methods. 并且做GWT.create(B.class)我得到B接口的实现,但没有实现A接口方法。

And get compilation error: 并获得编译错误:

[Error] Line 3: The type B_impl must implement the abstract method A.someMethod() [错误]第3行:类型B_impl必须实现抽象方法A.someMethod()

Additional: As i find out later, may be it's connected with Annotations. 附加:正如我后来发现的,可能是它与Annotations有关。

So i have: 所以我有:

public interface annotationHelperClass{
}

that has: 具有:

public final class annotationHelperClassGenerator{
//Some code
}

annotation: 注解:

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

so interface A will be: 所以接口A将是:

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

interface B: 界面B:

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

The problem was that my generator use: 问题是我的发电机使用:

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

So changing getMethods() on getInheritableMethods() solved this problem. 因此,在getInheritableMethods()上更改getMethods()可以解决此问题。

Sorry for being not in detail, i was not sure what is important in this case! 很抱歉没有详细说明,我不确定在这种情况下重要的是什么!

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

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