I need to pass .class for a Java interface to a function call in Clojure.
Calling (class ) requires an instance of the object, where as I want the static class name.
Basically so I can java interop and use: keysetHandle.getPrimitive(Aead.class);
Passing Aead but Aead is only an interface want it like so but cannot work out how to get the equivalent Aead.class in Clojure?
(.getPrimitive keyset-handle Aead.class)
Have you tried (.getPrimitive keyset-handle Aead)
?
You should be able to pass the class of your interface just by using its name. An example Java class:
public class Foo {
public <P> String bar(Class<P> klass) {
return klass.getCanonicalName();
}
}
Then in a REPL, using the java.util.List
interface for example:
user=> (import Foo)
Foo
user=> (.bar (Foo.) java.util.List)
"java.util.List"