Skip to content

Instantly share code, notes, and snippets.

@eiennohito
Created March 24, 2016 08:19
Show Gist options
  • Save eiennohito/68ceb4ca836b466d3068 to your computer and use it in GitHub Desktop.
Save eiennohito/68ceb4ca836b466d3068 to your computer and use it in GitHub Desktop.
scala> def a = { val x = Array(1.2, 2.3); return x }
<console>:11: error: method a has return statement; needs result type
def a = { val x = Array(1.2, 2.3); return x }
^
scala> def a = { val x = Array(1.2, 2.3); x }
a: Array[Double]
scala> :scalap a
scalap: no such command. Type :help for help.
scala> :javap a
Size 613 bytes
MD5 checksum e6effd7520b9e489ff2488d014505082
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 a
#14 = Utf8 ()[D
#15 = Double 1.2d
#17 = Double 2.3d
#19 = Utf8 this
#20 = Utf8 x
#21 = Utf8 [D
#22 = Methodref #4.#11 // java/lang/Object."<init>":()V
#23 = NameAndType #6:#7 // MODULE$:L;
#24 = Fieldref #2.#23 // .MODULE$:L;
#25 = Utf8
#26 = Class #25 //
#27 = Utf8 $line4/$read
#28 = Class #27 // $line4/$read
#29 = Utf8
#30 = Utf8 Code
#31 = Utf8 LocalVariableTable
#32 = Utf8 LineNumberTable
#33 = Utf8 SourceFile
#34 = Utf8 InnerClasses
#35 = Utf8 ScalaInlineInfo
#36 = 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 double[] a();
descriptor: ()[D
flags: ACC_PUBLIC
Code:
stack=5, locals=2, args_size=1
0: iconst_2
1: newarray double
3: dup
4: iconst_0
5: ldc2_w #15 // double 1.2d
8: dastore
9: dup
10: iconst_1
11: ldc2_w #17 // double 2.3d
14: dastore
15: astore_1
16: aload_1
17: areturn
LocalVariableTable:
Start Length Slot Name Signature
0 18 0 this L;
16 1 1 x [D
LineNumberTable:
line 11: 0
public ();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #22 // Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #24 // Field MODULE$:L;
8: return
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this L;
LineNumberTable:
line 15: 0
}
SourceFile: "<console>"
InnerClasses:
public static #29= #26 of #28; //=class of class $line4/$read
public static #29= #2 of #26; //=class 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