【发布时间】:2014-05-06 12:50:42
【问题描述】:
我正在开发一个分析 Java 代码的 Java/Scala 项目。在我的 scala 代码中,我有:
package p{
object NodeKind{
// In real code they are not Int but this is good enough for the example
val `class` = 0
val interface = 0
}
}
我需要从 Java 访问它
class MyJavaClass{
void m(){
/* ... */
int value = p.NodeKind.//how can I access to `class` or interface ?
/* ... */
}
}
现在我已经解决了 Brian Agnew 解决方案,我添加了一个字段
val classKind = `class`
在我的 scala 对象中,我可以在我的 java 代码中使用 p.nodeKind.classKind() 访问它,但我真的更想知道 `class` 的编译(修改?)规则和直接访问它的接口。
【问题讨论】:
-
我不认为他有,是吗?
-
@p3rand0r 错误:meta.stackexchange.com/a/129632/165773
-
你说得对,我错了
-
根据您的建议,我在 stackexchange 上发布了问题:programmers.stackexchange.com/questions/238090/…
-
他们告诉我这个问题确实属于这里:s