3

I was wondering if there is a way of renaming an imported Java Type in clojure.

Something like this:

(ns foo (:import java.util.List :as JList))

If not; Do I have to then reference the type as FQCN (fully qualified class name)?

UPDATE:

This example is a bit contrived, I know that I can reference Java classes once imported without FQCN. The real problem is that I have a class that has the same name as a default imported class, for instance in java.lang.

ngarthl
  • 433
  • 2
  • 9

2 Answers2

5

It's not possible to rename a Java type.

dnolen
  • 18,496
  • 4
  • 62
  • 71
  • But any ideas on how to import e.g. `org.jpl7.Float` witout the error `Float already refers to: class java.lang.Float ...`? – Erik Kaplun Dec 30 '19 at 21:56
0

Once you import the class, you no longer have to use the full name:

user> (import java.util.List) 
java.util.List  
user> List 
java.util.List

It adds the class name to the current namespace for you.

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284