Hello ) I have one abstract class and several concrete classes in Java
abstract class SpecificRecordBase {}
class A extends SpecificRecordBase
class B extends SpecificRecordBase
....
Also I have a map in Scala. I want to put key String and value as a class to use it in method:
def test(m: Map[String, Class[_ <: SpecificRecordBase]]):Unit = ???
I tried to ClassTag(ClassLoader.getSystemClassLoader.loadClass(stringClassName)).runtimeClass but got an error. Also I tried to create method and use it
def getClass[T <: SpecificRecordBase](ct: ClassTag[T]): Class[T] = ct.runtimeClass
And also have an error
Error:(10, 73) type mismatch;
found : Class[_$1] where type _$1
required: Class[T]
def getClass[T <: SpecificRecordBase](ct: ClassTag[T]): Class[T] = ct.runtimeClass
Could you help me please?
Aucun commentaire:
Enregistrer un commentaire