Skip to content

Instantly share code, notes, and snippets.

@umireon
Created April 30, 2021 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umireon/00da8dbab2b6bf926d83a646fc7589b7 to your computer and use it in GitHub Desktop.
Save umireon/00da8dbab2b6bf926d83a646fc7589b7 to your computer and use it in GitHub Desktop.
Scala trait ABI
package main;
public interface TestTrait {
public default int method(int x) {
return x * 2;
}
}
package main
trait TestTrait {
def method(x: Int): Unit = {
x * 2
}
}
// Generated by running 'javap -c TestTrait'
Compiled from "TestTrait.java"
public interface main.TestTrait {
public int method(int);
Code:
0: iload_1
1: iconst_2
2: imul
3: ireturn
}
// Generated by running 'javap -c TestTrait'
Compiled from "TestTrait.scala"
public interface main.TestTrait {
public static void method$(main.TestTrait, int);
Code:
0: aload_0
1: iload_1
2: invokespecial #16 // InterfaceMethod method:(I)V
5: return
public void method(int);
Code:
0: iload_1
1: iconst_2
2: imul
3: pop
4: return
public static void $init$(main.TestTrait);
Code:
0: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment