Field Method Conflicts

Nathan Faulkner natedogith1 at gmail.com
Fri Jan 19 09:31:58 UTC 2018


Is there any way, other than reflection, to access a field that shares a
name with a method? It seems that, with the Test class,  instance.item
returns the item() dynamic method (as does instance["item"]), and
instance.item2 returns "b".

public class Test {
  public String item = "1";
  public String item2 = "2";

  public String item() {
    return "a";
  }

  public String getItem2() {
    return "b";
  }
}


Thanks,
Nathan Faulkner


More information about the nashorn-dev mailing list