12
I'd like to have a method like
def retrieve[T](value: Option[T])(implicit ct: ClassTag[T]): T;
Inside this method I need to call a Java method (beyond my control) to create an instance of T that requires Class[T]:
public <T> T construct(clazz: Class<T> /* other arguments */) { ... }
How can I get Class[T] from ClassTag[T]? First I thought I could use runtimeClass from ClassTag, but it's type is Class[_], not Class[T]. Or is there any other implicit value that compiler can automatically provide, from which I can obtain Class[T]?