cursive

Yevgeni Tsodikov 2026-01-20T18:38:25.171669Z

Hey, Question about definterface. When using a definterface we have to qualify all classnames, else Clojure just prefixes the classes with java.lang.. Example:

(definterface IDoStuff
  (^CompletableFuture stuffAsync [^String input ^Map option]))
=> user.IDoStuff
(deftype StuffImpl []
  IDoStuff
  (stuffAsync [_ input option]))
Syntax error (ClassNotFoundException) compiling deftype* at (/private/var/folders/8t/5j07pp9n2371mgs0zzl6d8040000gp/T/form-init8973514254085745336.clj:1:1).
java.lang.Map
When using fully qualified class names, everything works:
(definterface IDoStuff
  (^java.util.concurrent.CompletableFuture stuffAsync [^String input ^java.util.Map option]))
=> user.IDoStuff
(deftype StuffImpl []
  IDoStuff
  (stuffAsync [_ input option]))
=> user.StuffImpl
But now the IDE is falsely claiming I can shorten them, but it's wrong. What would be the best to address it? (Other then simply writing a plain .java file)

Alex Miller (Clojure team) 2026-01-20T18:47:03.469419Z

It's not wrong - if you import, you can shorten them. But you might need to reload the namespace for the added imports to take effect?

Alex Miller (Clojure team) 2026-01-20T18:48:20.469759Z

for example (outside the IDE):

$ clj
Clojure 1.12.4
user=> (import [java.util Map] [java.util.concurrent CompletableFuture])
java.util.concurrent.CompletableFuture
user=> (definterface IDoStuff
  (^CompletableFuture stuffAsync [^String input ^Map option]))
user.IDoStuff
^^ works fine (but I evaled the import there)

Alex Miller (Clojure team) 2026-01-20T18:49:15.068759Z

and fyi, Clojure does not prefix the class names, rather most of the classes in java.lang are auto-imported by ns

Yevgeni Tsodikov 2026-01-20T18:49:40.536529Z

> ^^ works fine (but I evaled the import there) It breaks when you write the deftype

Yevgeni Tsodikov 2026-01-20T18:51:40.831059Z

This is outside the IDE as well, from lein repl:

nREPL server started on port 56319 on host 127.0.0.1 - 
REPL-y 0.5.1, nREPL 1.3.0
Clojure 1.12.2
OpenJDK 64-Bit Server VM 17.0.6+10-LTS
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (import [java.util Map] [java.util.concurrent CompletableFuture])
java.util.concurrent.CompletableFuture
user=> (definterface IDoStuff
  #_=>   (^CompletableFuture stuffAsync [^String input ^Map option]))
user.IDoStuff
user=> (deftype StuffImpl []
  #_=>   IDoStuff)
Syntax error (ClassNotFoundException) compiling deftype* at (REPL:1:1).
java.lang.Map

user=> (deftype StuffImpl []
  #_=>   IDoStuff
  #_=>   (stuffAsync [_ input options]))
Syntax error (ClassNotFoundException) compiling deftype* at (REPL:1:1).
java.lang.Map

Alex Miller (Clojure team) 2026-01-20T18:51:48.025249Z

I see, thanks

Alex Miller (Clojure team) 2026-01-20T18:51:54.303979Z

I think this is a bug in Clojure, not Cursive :)

Yevgeni Tsodikov 2026-01-20T18:52:04.525159Z

😬

Alex Miller (Clojure team) 2026-01-20T18:52:29.954699Z

looks like same as https://ask.clojure.org/index.php/4260/definterface-seems-not-resolve-imported-classes-type-hints?show=4260#q4260 if you want to up-vote this

Yevgeni Tsodikov 2026-01-20T18:53:24.557139Z

Upvoted, thanks!

Alex Miller (Clojure team) 2026-01-20T18:56:19.830909Z

I'll have someone look at that, certainly was not in my memory banks!

🙏 1
cfleming 2026-01-21T09:17:00.320119Z

> I think this is a bug in Clojure, not Cursive 🙂 I've very often thought this to be the case, but I'm nearly always wrong 🙂

😂 2