简体   繁体   中英

Scala classOf on class with recursive type parameter

I need to call classOf on a class written in Java as follows:

public class Order<I extends Item> {...}

where Item is like the following

public class Item<O extends Order> {...}

Then I need to pass the class of Order to some method. In Java, it is Order.class . But in Scala, I have to use classOf(Order[Item[Order....) .

What is the right way to get the Order 's class in Scala?

How about simply classOf[Order[_]] ?

(BTW, your Java declarations are using raw types — most likely, you'll need to declare things like class Order<O extends Order<O, I>, I extends Item<O, I>> and class Item<O extends Order<O, I>, I extends Item<O, I>> .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM