Should we use the ScalaSignature directly?

本小妞迷上赌 提交于 2019-11-30 02:56:19

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/11985096/should-we-use-the-scalasignature-directly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!