1

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?

3
  • Nothing is clear from your public class Order and public class Item. Please provide more details about these classes Commented Sep 13, 2013 at 7:08
  • val orderClass = classOf[Order] should give Order class Commented Sep 13, 2013 at 7:27
  • @rags No, that won't work for parametrized types. Commented Sep 13, 2013 at 8:00

1 Answer 1

3

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>>.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.