1

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);

Java Source method call

Interface to call .class on

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)

1 Answer 1

5

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"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.