Skip to content

Instantly share code, notes, and snippets.

@lrytz
Last active Aug 29, 2015
Embed
What would you like to do?
public class A {
public static final int N = 0;
}
scalaVersion := "2.11.2"
class C {
def foo = A.N
}
/*
lucmac:test luc$ sbt clean compile && javap -c -classpath target/scala-2.11/classes C | grep "public int foo" -A 4
[info] Loading global plugins from /Users/luc/.sbt/0.13/plugins
[info] Set current project to test (in build file:/Users/luc/scala/scala/sandbox/test/)
[success] Total time: 0 s, completed Oct 20, 2014 2:33:50 PM
[info] Updating {file:/Users/luc/scala/scala/sandbox/test/}test...
[info] Resolving jline#jline;2.12 ...
[info] Done updating.
[info] Compiling 1 Scala source and 1 Java source to /Users/luc/scala/scala/sandbox/test/target/scala-2.11/classes...
[success] Total time: 3 s, completed Oct 20, 2014 2:33:53 PM
public int foo();
Code:
0: getstatic #16; //Field A.N:I
3: ireturn
lucmac:test luc$ rm target/scala-2.11/classes/C.class && sbt compile && javap -c -classpath target/scala-2.11/classes C | grep "public int foo" -A 4
[info] Loading global plugins from /Users/luc/.sbt/0.13/plugins
[info] Set current project to test (in build file:/Users/luc/scala/scala/sandbox/test/)
[info] Compiling 1 Scala source to /Users/luc/scala/scala/sandbox/test/target/scala-2.11/classes...
[success] Total time: 2 s, completed Oct 20, 2014 2:34:00 PM
public int foo();
Code:
0: iconst_0
1: ireturn
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment