我com.rabbitmq.client.ConnectionFactory.newConnection(Address[])
从 Clojure 1.4.0 调用,如下所示:
(defn connect [#^ConnectionFactory factory, addrs]
(.newConnection factory (into-array Address addrs)))
该调用有效,但会引发反射警告:
call to newConnection can't be resolved.
回顾ConnectionFactory
类,显然有一种形式只接受一个类型的参数com.rabbitmq.client.Address[]
,这正是(into-array Address ())
返回的内容:
com.mefesto.wabbitmq=> (pprint (filter #(.. (.toString %)
(contains "newConnection"))
(seq (.getDeclaredMethods
ConnectionFactory))))
(#<Method public com.rabbitmq.client.Connection
com.rabbitmq.client.ConnectionFactory.newConnection(
com.rabbitmq.client.Address[])
throws java.io.IOException>
#<Method public com.rabbitmq.client.Connection
com.rabbitmq.client.ConnectionFactory.newConnection(
java.util.concurrent.ExecutorService,
com.rabbitmq.client.Address[])
throws java.io.IOException>
#<Method public com.rabbitmq.client.Connection
com.rabbitmq.client.ConnectionFactory.newConnection()
throws java.io.IOException>
#<Method public com.rabbitmq.client.Connection
com.rabbitmq.client.ConnectionFactory.newConnection(
java.util.concurrent.ExecutorService)
throws java.io.IOException>)
com.mefesto.wabbitmq=> (into-array Address ())
#<Address[] [Lcom.rabbitmq.client.Address;@953235f>
我需要做些什么来避免在这里反射?