Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we use the ScalaSignature directly?

The ScalaSignature is an annotation. It contains meta informations.

  • https://github.com/scala/scala/blob/v2.9.2/src/library/scala/reflect/ScalaSignature.java

And then parser is provided. but scala-library.jar is not contains the parser. It seem like secret API.

  • https://github.com/scala/scala/blob/v2.9.2/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala

But I know a few libraries using ScalaSignature.

  • https://github.com/lift/framework/blob/2.4-release/core/json/src/main/scala/net/liftweb/json/ScalaSig.scala
  • https://github.com/msgpack/msgpack-scala/blob/version-0.6.6/src/main/scala/org/msgpack/scalautil/ScalaSigUtil.scala
  • https://github.com/havocp/beaucatcher/blob/v0.5.0/caseclass/src/main/scala/org/beaucatcher/caseclass/ClassAnalysis.scala

By the way, I could not found formal specification of ScalaSignature. I worry that the specification of ScalaSignature may change by a Scala version change. Also I think there are some other risks using ScalaSignature because specification doesn't exists.

Further, Scala2.10 will provide a new reflection API. I think the reason for using ScalaSignature will decrease, when 2.10 is released.

Thus, should one use the ScalaSignature?

like image 531
Kenji Yoshida Avatar asked Aug 16 '12 10:08

Kenji Yoshida


1 Answers

Reflection API in Scala 2.10 provides an officially supported abstraction over Java reflection + Scala signatures. If ScalaSignature format changes, reflection will change accordingly.

like image 80
Eugene Burmako Avatar answered Nov 09 '22 05:11

Eugene Burmako