为什么在运行时无法访问用 Scala 编写的注释?

Why annotations written in Scala are not accessible at runtime?

我在 scalatest 文档中看到一个声明:

It must be defined in Java instead of Scala so it will be accessible at runtime.

这很奇怪,因为我的印象是 Scala 注释比它的 Java 注释更强大。为什么缺少此功能?有计划加回去吗?

没有已知的计划在运行时保留 Scala 支持注释(这个问题已经知道一段时间了,但正如 this page 所说,它不会被修复)。

Lukas Rytz, a Scala committer, explained on a postscala-language 邮件列表中:

It's definitely non-trivial. Java annotations have specific representation in bytecode [...], which would require changes to Scala's bytecode generator.

Also the language of java annotations is quite special, different from the rest of the Java language [...], so one would need to define how this can be represented in a Scala class.