Scala在哪里存储无法用Java表示的信息? [英] Where does Scala store information that cannot be represented in Java?

查看:91
本文介绍了Scala在哪里存储无法用Java表示的信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有些构造在Java中没有等效项。例如

There are some constructs that don't have equivalents in java. Examples would be


  • 命名参数

  • 实例私有成员

Scala在哪里/如何存储这些东西所需的信息(在第一种情况下为某种标志,在第二种情况下为参数名称?

Where/How does Scala store the information necessary for this stuff (some kind of flag in the first case, the parameter names in the second case?

如果我理解正确,则必须将其存储在字节码中,因为即使我只是一个没有源代码的编译库也可以正常工作!?

If I get it right this has to get stored in the byte code, since it works even if I just have a compiled library without the source code!?

推荐答案

此信息在类文件中名为 ScalaSig 的注释中捕获(请参阅此答案为例)。

This information is captured in an annotation named ScalaSig in the class file (see this answer for an example).

您可以查看(不是很友好) )使用 javap -verbose 使用内部API解析,但在g eneral 都不是必需的

You can view the (not very human-friendly) annotation with javap -verbose, or parse it using an internal API, but in general neither should be necessary.

这篇关于Scala在哪里存储无法用Java表示的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆