scala protected modifier convert to java class is public

Viewed 449

In a scala class, I have defined a protected field and a protected method:

TestProtected.scala:

class TestProtected {
  protected var f = 0

  protected def m = 1
}

In my opinion, it will convert the protected f and m to a java protected filed and method. But when i use jd-gui to decompiler the TestProtected.class to java file, the result was beyond my expectation:

@ScalaSignature(bytes="...")
public class TestProtected
{
  private int f= 0;

  public int f() { return this.f; } 
  public void f$eq(int x$1) { this.f = x$1; } 
  public int m() {
    return 1;
  }
}

The f and m in java file is public?

Why?

Thanks!

2 Answers
Related