Search code examples
clojureclojure-java-interop

Calling java parent method from Clojure


Say I have a java library with the following pseudo code :

abstract class B {
    public void method2(String param2) {...}
}

class A extends B {
    public void method1(String param1) {...}
}

I want to use this from Clojure.

I have an instance of A, and I want to invoke method2 without going through Reflection methods.

What's the quickest way ?


Solution

  • If you have an instance of A you can just call method2 using normal interop:

    (.method2 (A.) "param")