I am new to Scala. I read that the protectedScala keyword is different from protectedin Java. When I saw the byte code generated for the protected public class method in Scala and java, I found the following:
Scala code:
package com.test
class Vehicle {
protected def ignite() {
println("Ignition.....")
}
}
when I decompiled with javap, it shows the following code:
public class com.test.Vehicle {
public void ignite();
public com.test.Vehicle();
}
And also flags: ACC_PUBLICset in the method descriptor ignitefor Scala.
Java equivalent code:
package com.test;
public class Vehicle {
protected void ignite() {
System.out.println("Ignition.....");
}
}
and compiled code:
public class com.test.Vehicle {
public com.test.Vehicle();
protected void ignite();
}
It is also flags: ACC_PROTECTEDset in the method descriptor ignitefor Java.
But still it gives a different behavior than JAVA.
How is this thing handled by the JVM?
Note. I do not have knowledge of the JVM specification.