0
리플렉션을 사용하여 deep equals 비교를 구현하려고합니다. 그 때문에 런타임에 주어진 객체에 목록을 찾아야합니다 (이 객체 아래의 예제에서는 Foo
이라고 함).스칼라 리플렉션 : 지정된 유형의 val을 찾는 방법?
내 느낌은 그러나 나는 lists
이 list1
및 list2
를 가리키는 기호를 포함하도록 ??? what should go here ???
부분에 넣어 무엇을 알아낼 수 없습니다, 아래 코드는 올바른 방향으로 가고 있다는 것입니다?
??? what should go here ???
에 listType
을 입력하면 lists
이 비어있게됩니다.
val
에 관심이 있다면
import scala.reflect.runtime.universe._
import java.util
class Foo{
val one=1
val list1=new util.ArrayList[Int]
val list2=new util.ArrayList[Int]
}
val foo=new Foo
val m= runtimeMirror(getClass.getClassLoader)
val theType =m.reflect(foo).symbol.toType
val listType = typeOf[util.List[_]]
val lists=theType.members.filter( _.typeSignature == ??? what should go here ???)