sramsay
sramsay

Reputation: 43

How do I call a non-public method of a public class in Clojure?

I'm calling the twitter4j library using Clojure like so:

(def twitter (. (TwitterFactory.) getInstance))

This works fine when I call it as a script. But when I use gen-class, I get:

java.lang.IllegalArgumentException: Can't call public method of non-public class: public java.lang.Object twitter4j.TwitterFactoryBase.getInstance()

Is there a workaround for this?

Upvotes: 4

Views: 620

Answers (2)

Miki Tebeka
Miki Tebeka

Reputation: 13850

Try:

(def twitter (.getInstance (new TwitterFactory)))

Upvotes: 0

Michael Kohl
Michael Kohl

Reputation: 66837

I have no experience with it myself, but Meikel Brandmeyer did a nice writeup on gen-class once, maybe that will help you:

http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_to_use_it.html

Upvotes: 1

Related Questions