For the interface...
package foo;
public interface Iface {
String X = "Hello, World!";
void invoke();
}
...static member¹ X
can be accessed two ways.
1) Via the type:
var x = Packages.foo.Iface.X;
2) Via reflection:
var impl = new Packages.foo.Iface({
invoke : function () {
var x = this.getClass().getField("X").get(null);
java.lang.System.out.println(x);
}
});
impl.invoke();
Tested on Rhino 1.7R4.
¹All variables are implicitly public static final
on interfaces.