java类。getAnnotation和getAnnotations无法正常工作
来自gwt的类SecureDispatchService
如下所示:
@RemoteServiceRelativePath("dispatch")
public interface SecureDispatchService extends RemoteService {
Result execute( String sessionId, Action<?> action ) throws DispatchException;
}
RemoteServiceRelativePath
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RemoteServiceRelativePath {
/**
* The relative path for the {@link RemoteService} implementation.
*
* @return relative path for the {@link RemoteService} implementation
*/
String value();
}
测试代码非常简单:
package com.name.sbts.wbts.sm;
import net.customware.gwt.dispatch.client.secure.SecureDispatchService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
public class TestClass {
public static void main(String[] args) {
Class c = SecureDispatchService.class;
System.out.println(c.getAnnotation(RemoteServiceRelativePath.class));
System.out.println(c.getAnnotations().length);
}
}
但结果并不理想:
null
0
我在eclipse中用JRE1运行这段代码。七,
SecureDispatchService
在谷歌的这个罐子里:
gwt-dispatch-1.2.0.jar
我用mvn eclipse:eclipse
生成了这个项目。
这个jar文件是eclipse项目的一个参考库,它的实际路径在我的。m2/个故事
共 (0) 个答案