0

我正在尝试让 AutoBean 中的 @Category(class) 工作。

我有一个简单的工厂

import com.google.web.bindery.autobean.shared.AutoBean;
import com.google.web.bindery.autobean.shared.AutoBeanFactory.Category;

@Category(TestCategory.class)
public interface TestFactory {
    AutoBean<Test> test();
}

和类别类

导入 com.google.web.bindery.autobean.shared.AutoBean;

public class TestCategory {
    public static String asString(AutoBean<Test> instance) {
        return "as a string";
    }
}

和测试接口。

public interface Test {
    String getValue();
    void setValue(String value);
    String asString();
}

这三个都在同一个包中。

当我尝试编译 GWT 项目时,我收到以下错误消息

 [java]    Resolving com.mycompany.my_gwt_project.client.test.TestFactory
 [java]       Found type 'com.mycompany.my_gwt_project.client.test.TestFactory'
 [java]          [ERROR] Annotation error: cannot resolve com.mycompany.my_gwt_project.client.test.TestCategory
 [java]    java.lang.ClassNotFoundException: com.mycompany.my_gwt_project.client.test.TestCategory
 [java]     at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
 [java]     at java.security.AccessController.doPrivileged(Native Method)
 [java]     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
 [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
 [java]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 [java]     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
 [java]     at java.lang.Class.forName0(Native Method)
 [java]     at java.lang.Class.forName(Class.java:249)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotationValue(TypeOracleMediator.java:750)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotationValue(TypeOracleMediator.java:689)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.createAnnotation(TypeOracleMediator.java:498)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotation(TypeOracleMediator.java:648)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotations(TypeOracleMediator.java:663)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.resolveClass(TypeOracleMediator.java:809)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediator.addNewTypes(TypeOracleMediator.java:439)
 [java]     at com.google.gwt.dev.javac.TypeOracleMediatorFromSource.addNewUnits(TypeOracleMediatorFromSource.java:52)
 [java]     at com.google.gwt.dev.javac.CompilationState.assimilateUnits(CompilationState.java:164)
 [java]     at com.google.gwt.dev.javac.CompilationState.<init>(CompilationState.java:82)
 [java]     at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:466)
 [java]     at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:388)
 [java]     at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:373)
 [java]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:246)
 [java]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
 [java]     at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
 [java]     at com.google.gwt.dev.Compiler.run(Compiler.java:232)
 [java]     at com.google.gwt.dev.Compiler.run(Compiler.java:198)
 [java]     at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
 [java]     at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
 [java]     at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
 [java]     at com.google.gwt.dev.Compiler.main(Compiler.java:177)
 [java]          [ERROR] Annotation error: expected class java.lang.Class, got null

有人有任何线索吗?

4

1 回答 1

0

您必须将javac您的类包含在 DevMode 的类路径中。

不幸的是,这是 GWT 当前设计的一个已知限制:https ://code.google.com/p/google-web-toolkit/issues/detail?id=7602

于 2013-04-18T13:02:52.927 回答