Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why must these Java class names be fully qualified in Clojure?

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:?

like image 888
Ralph Avatar asked Feb 10 '26 22:02

Ralph


1 Answers

gen-class and gen-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.

like image 166
ponzao Avatar answered Feb 12 '26 16:02

ponzao



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!