使用Ruby to Java Bridge(RJB)如何使用通用签名访问Scala类?

时间:2013-02-22 23:26:58

标签: java ruby scala rjb

例如,尝试从Ruby访问Kafka的Scala / Java API(在require和Rjb :: load步骤之后)

ProducerData = Rjb::import('kafka.javaapi.producer.ProducerData')
topic = "test"
msg = "message"
producer_data = ProducerData.new_with_sig('Ljava.lang.String;Ljava.lang.String;',topic,msg)

在Kafka API中,ProducerData方法定义为:

class ProducerData[K, V](private val topic: String,
                     private val key: K,
                     private val data: java.util.List[V]) 

运行文件后的结果是:

./test-rjb.rb:30:in `new_with_sig': Constructor not found (RuntimeError)

如何正确访问具有泛型类型签名的类?

0 个答案:

没有答案