Skip to content

Instantly share code, notes, and snippets.

@tixxit
Created April 30, 2015 14:28
Show Gist options
  • Save tixxit/cacceaff6b25bafb2816 to your computer and use it in GitHub Desktop.
Save tixxit/cacceaff6b25bafb2816 to your computer and use it in GitHub Desktop.
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> object Blah {
| def thing[A](a: Option[A]): Int = a match {
| case Some(x) => 23
| case None => 42
| }
| }
defined object Blah
scala> :javap Blah
Size 952 bytes
MD5 checksum 010c9f62601e50b75cff4036fe3d146d
Compiled from "<console>"
public class Blah$
SourceFile: "<console>"
InnerClasses:
public static #43= #40 of #42; //=class of class $line3/$read
public static #43= #45 of #40; //=class of class
public static #46= #2 of #45; //Blah$=class Blah$ of class
Scala: length = 0x0
minor version: 0
major version: 50
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Utf8 Blah$
#2 = Class #1 // Blah$
#3 = Utf8 java/lang/Object
#4 = Class #3 // java/lang/Object
#5 = Utf8 <console>
#6 = Utf8 MODULE$
#7 = Utf8 LBlah$;
#8 = Utf8 <clinit>
#9 = Utf8 ()V
#10 = Utf8 <init>
#11 = NameAndType #10:#9 // "<init>":()V
#12 = Methodref #2.#11 // Blah$."<init>":()V
#13 = Utf8 thing
#14 = Utf8 (Lscala/Option;)I
#15 = Utf8 scala/Some
#16 = Class #15 // scala/Some
#17 = Utf8 scala/None$
#18 = Class #17 // scala/None$
#19 = Utf8 Lscala/None$;
#20 = NameAndType #6:#19 // MODULE$:Lscala/None$;
#21 = Fieldref #18.#20 // scala/None$.MODULE$:Lscala/None$;
#22 = Utf8 equals
#23 = Utf8 (Ljava/lang/Object;)Z
#24 = NameAndType #22:#23 // equals:(Ljava/lang/Object;)Z
#25 = Methodref #4.#24 // java/lang/Object.equals:(Ljava/lang/Object;)Z
#26 = Utf8 scala/MatchError
#27 = Class #26 // scala/MatchError
#28 = Utf8 (Ljava/lang/Object;)V
#29 = NameAndType #10:#28 // "<init>":(Ljava/lang/Object;)V
#30 = Methodref #27.#29 // scala/MatchError."<init>":(Ljava/lang/Object;)V
#31 = Utf8 this
#32 = Utf8 a
#33 = Utf8 Lscala/Option;
#34 = Utf8 scala/Option
#35 = Class #34 // scala/Option
#36 = Methodref #4.#11 // java/lang/Object."<init>":()V
#37 = NameAndType #6:#7 // MODULE$:LBlah$;
#38 = Fieldref #2.#37 // Blah$.MODULE$:LBlah$;
#39 = Utf8
#40 = Class #39 //
#41 = Utf8 $line3/$read
#42 = Class #41 // $line3/$read
#43 = Utf8
#44 = Utf8
#45 = Class #44 //
#46 = Utf8 Blah$
#47 = Utf8 Code
#48 = Utf8 LocalVariableTable
#49 = Utf8 LineNumberTable
#50 = Utf8 StackMapTable
#51 = Utf8 Signature
#52 = Utf8 <A:Ljava/lang/Object;>(Lscala/Option<TA;>;)I
#53 = Utf8 SourceFile
#54 = Utf8 InnerClasses
#55 = Utf8 Scala
{
public static final Blah$ MODULE$;
flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
public static {};
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=1, locals=0, args_size=0
0: new #2 // class Blah$
3: invokespecial #12 // Method "<init>":()V
6: return
public <A extends java/lang/Object> int thing(scala.Option<A>);
flags: ACC_PUBLIC
Code:
stack=3, locals=4, args_size=2
0: aload_1
1: astore_2
2: aload_2
3: instanceof #16 // class scala/Some
6: ifeq 15
9: bipush 23
11: istore_3
12: goto 28
15: getstatic #21 // Field scala/None$.MODULE$:Lscala/None$;
18: aload_2
19: invokevirtual #25 // Method java/lang/Object.equals:(Ljava/lang/Object;)Z
22: ifeq 30
25: bipush 42
27: istore_3
28: iload_3
29: ireturn
30: new #27 // class scala/MatchError
33: dup
34: aload_2
35: invokespecial #30 // Method scala/MatchError."<init>":(Ljava/lang/Object;)V
38: athrow
LocalVariableTable:
Start Length Slot Name Signature
0 39 0 this LBlah$;
0 39 1 a Lscala/Option;
LineNumberTable:
line 8: 0
line 9: 2
line 10: 15
line 8: 28
StackMapTable: number_of_entries = 3
frame_type = 252 /* append */
offset_delta = 15
locals = [ class scala/Option ]
frame_type = 252 /* append */
offset_delta = 12
locals = [ int ]
frame_type = 250 /* chop */
offset_delta = 1
Signature: #52 // <A:Ljava/lang/Object;>(Lscala/Option<TA;>;)I
public Blah$();
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #36 // Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #38 // Field MODULE$:LBlah$;
8: return
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this LBlah$;
LineNumberTable:
line 16: 0
}
scala>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment