Using the Ruby to Java Bridge (RJB) how can I access Scala classes with generic signatures?

363 Views Asked by At

As an example, trying to access the Scala/Java API for Kafka from Ruby, (after the require and Rjb::load steps)

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)

In the Kafka API, the ProducerData method is defined as:

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

The result after running the file is:

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

How can I properly access classes with generic type signatures?

0

There are 0 best solutions below