2

It appears that I'm unable to access a Scala method default() from Java code.

scala> class A {
     | def default = 3
     | }
defined class A

scala> :javap -public A
Compiled from "<console>"
public class A {
  public int default();
  public A();
}

Trying to access default() in Java code yields all kind of syntax errors. Is there a workaround like Scala's backticks to handle Java keywords?

Taig
  • 6,718
  • 4
  • 44
  • 65
  • 1
    http://stackoverflow.com/questions/423994/reserved-words-as-variable-or-method-names – Michael Zajac Aug 25 '15 at 19:01
  • I was hoping Scala might do some magic here. When working with IntelliJ it offers `_mthdefault()` as auto complete option. The method doesn't really exist, though. Therefore it does not compile or show up in javap. I'm just hoping I'm overlooking something here. – Taig Aug 25 '15 at 19:04
  • 1
    Maybe with reflection, but otherwise, I don't think so. – Michael Zajac Aug 25 '15 at 19:07

0 Answers0