为什么这些 Java 类名必须在 Clojure 中完全限定?
我正在定义一个与 JAX-RS REST 服务器一起使用的 definterface
(RESTEasy):
(ns com.example.server.resources.buildtime
(:import [javax.ws.rs.core Cookie UriInfo]))
(definterface BuildTime
(getBuildTime [^UriInfo info
^Cookie security-cookie]))
当我 AOT 编译这个类时,出现以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: java/lang/UriInfo, compiling:(com/example/server/resources/buildtime.clj:13)
如果我将注释更改为以下内容,错误就会消失:
(definterface BuildTime
(getBuildTime [^javax.ws.rs.core.UriInfo info
^javax.ws.rs.core.Cookie security-cookie]))
当使用导入类时,为什么注释必须具有完全限定的类名导入:
?
I am defining a definterface
to be used with a JAX-RS REST server (RESTEasy):
(ns com.example.server.resources.buildtime
(:import [javax.ws.rs.core Cookie UriInfo]))
(definterface BuildTime
(getBuildTime [^UriInfo info
^Cookie security-cookie]))
When I AOT compile this class, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: java/lang/UriInfo, compiling:(com/example/server/resources/buildtime.clj:13)
If I change the annotations to the following, the error goes away:
(definterface BuildTime
(getBuildTime [^javax.ws.rs.core.UriInfo info
^javax.ws.rs.core.Cookie security-cookie]))
Why must the annotations have fully-qualified class names when the classes have been imported using import:
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
gen-class
和gen-interface
都要求类按照文档中所述完全限定 http://clojuredocs.org/clojure_core/clojure.core/gen-interface 和 http://clojuredocs.org/clojure_core/clojure.core/gen-interface。我不知道为什么会这样。gen-class
andgen-interface
both require the class to be fully qualified as stated in the docs http://clojuredocs.org/clojure_core/clojure.core/gen-interface and http://clojuredocs.org/clojure_core/clojure.core/gen-interface. I am not aware why this is so.