Skip to content

Instantly share code, notes, and snippets.

@kmizu
Created July 10, 2011 07:36
Show Gist options
  • Save kmizu/1074357 to your computer and use it in GitHub Desktop.
Save kmizu/1074357 to your computer and use it in GitHub Desktop.
A case that "private" method of Scala is compiled into "public" method of class file.
class Foo {
private def foo {
Foo.foo
}
}
object Foo {
private def foo {
println("foo")
}
}
Compiled from "Foo.scala"
public final class Foo$ extends java.lang.Object implements scala.ScalaObject{
public static final Foo$ MODULE$;
public static {};
Code:
0: new #9; //class Foo$
3: invokespecial #12; //Method "<init>":()V
6: return
public final void Foo$$foo();
Code:
0: getstatic #18; //Field scala/Predef$.MODULE$:Lscala/Predef$;
3: ldc #21; //String foo
5: invokevirtual #25; //Method scala/Predef$.println:(Ljava/lang/Object;)V
8: return
}
Compiled from "Foo.scala"
public class Foo extends java.lang.Object implements scala.ScalaObject{
public static final void Foo$$foo();
Code:
0: getstatic #11; //Field Foo$.MODULE$:LFoo$;
3: invokevirtual #13; //Method Foo$.Foo$$foo:()V
6: return
public Foo();
Code:
0: aload_0
1: invokespecial #20; //Method java/lang/Object."<init>":()V
4: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment