Skip to content

Instantly share code, notes, and snippets.

@mpilquist
Created October 17, 2016 22:18
Show Gist options
  • Save mpilquist/e119f3578e6e43ab1afe1e91e7039ae0 to your computer and use it in GitHub Desktop.
Save mpilquist/e119f3578e6e43ab1afe1e91e7039ae0 to your computer and use it in GitHub Desktop.
scala> case class Foo(x: Int, y: Boolean)
defined class Foo
scala> def foo(a: Foo) = a match { case Foo(x, y) => x }
foo: (a: Foo)Int
scala> :javap foo
Size 902 bytes
MD5 checksum 407f62b7f6559375f60f39b82fc98b9b
Compiled from "<console>"
public class
minor version: 0
major version: 50
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Utf8
#2 = Class #1 //
#3 = Utf8 java/lang/Object
#4 = Class #3 // java/lang/Object
#5 = Utf8 <console>
#6 = Utf8 MODULE$
#7 = Utf8 L;
#8 = Utf8 <clinit>
#9 = Utf8 ()V
#10 = Utf8 <init>
#11 = NameAndType #10:#9 // "<init>":()V
#12 = Methodref #2.#11 // ."<init>":()V
#13 = Utf8 foo
#14 = Utf8 (LFoo;)I
#15 = Utf8 Foo
#16 = Class #15 // Foo
#17 = Utf8 x
#18 = Utf8 ()I
#19 = NameAndType #17:#18 // x:()I
#20 = Methodref #16.#19 // Foo.x:()I
#21 = Utf8 scala/MatchError
#22 = Class #21 // scala/MatchError
#23 = Utf8 (Ljava/lang/Object;)V
#24 = NameAndType #10:#23 // "<init>":(Ljava/lang/Object;)V
#25 = Methodref #22.#24 // scala/MatchError."<init>":(Ljava/lang/Object;)V
#26 = Utf8 this
#27 = Utf8 a
#28 = Utf8 LFoo;
#29 = Utf8 I
#30 = Methodref #4.#11 // java/lang/Object."<init>":()V
#31 = NameAndType #6:#7 // MODULE$:L;
#32 = Fieldref #2.#31 // .MODULE$:L;
#33 = Utf8
#34 = Class #33 //
#35 = Utf8 $line4/$read
#36 = Class #35 // $line4/$read
#37 = Utf8
#38 = Utf8
#39 = Class #38 //
#40 = Utf8 $line3/$read
#41 = Class #40 // $line3/$read
#42 = Utf8
#43 = Class #42 //
#44 = Utf8 Foo
#45 = Utf8 Code
#46 = Utf8 LocalVariableTable
#47 = Utf8 LineNumberTable
#48 = Utf8 StackMapTable
#49 = Utf8 SourceFile
#50 = Utf8 InnerClasses
#51 = Utf8 ScalaInlineInfo
#52 = Utf8 Scala
{
public static final MODULE$;
descriptor: L;
flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
public static {};
descriptor: ()V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=1, locals=0, args_size=0
0: new #2 // class
3: invokespecial #12 // Method "<init>":()V
6: return
public int foo(Foo);
descriptor: (LFoo;)I
flags: ACC_PUBLIC
Code:
stack=3, locals=5, args_size=2
0: aload_1
1: astore_2
2: aload_2
3: ifnull 17
6: aload_2
7: invokevirtual #20 // Method Foo.x:()I
10: istore_3
11: iload_3
12: istore 4
14: iload 4
16: ireturn
17: new #22 // class scala/MatchError
20: dup
21: aload_2
22: invokespecial #25 // Method scala/MatchError."<init>":(Ljava/lang/Object;)V
25: athrow
LocalVariableTable:
Start Length Slot Name Signature
0 26 0 this L;
0 26 1 a LFoo;
11 15 3 x I
LineNumberTable:
line 13: 0
StackMapTable: number_of_entries = 1
frame_type = 252 /* append */
offset_delta = 17
locals = [ class Foo ]
public ();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #30 // Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #32 // Field MODULE$:L;
8: return
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this L;
LineNumberTable:
line 17: 0
}
SourceFile: "<console>"
InnerClasses:
public static #37= #34 of #36; //=class of class $line4/$read
public static #37= #39 of #41; //=class of class $line3/$read
public static #37= #2 of #34; //=class of class
public static #37= #43 of #39; //=class of class
public static #44= #16 of #43; //Foo=class Foo of class
Error: unknown attribute
ScalaInlineInfo: length = 0xE
01 01 00 02 00 0A 00 09 01 00 0D 00 0E 01
Error: unknown attribute
Scala: length = 0x0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment