Created
December 3, 2011 00:07
-
-
Save splittingfield/1425438 to your computer and use it in GitHub Desktop.
Boxing and unboxing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.azavea.math.Numeric | |
import com.azavea.math.EasyImplicits._ | |
class Blah[@specialized T:Numeric:Manifest] { | |
def blah[@specialized W:Numeric:Manifest](f:Function1[T,W]):W = { | |
f(numeric[T].zero) | |
} | |
def blah2(f:Function[T,T]):T = { | |
f(numeric[T].zero) | |
} | |
} | |
javap -verbose Blah\$mcI\$sp | |
public java.lang.Object blah$mcI$sp(scala.Function1, com.azavea.math.Numeric, scala.reflect.Manifest); | |
Code: | |
Stack=3, Locals=4, Args_size=4 | |
0: aload_1 | |
1: getstatic #32; //Field com/azavea/math/EasyImplicits$.MODULE$:Lcom/azavea/math/EasyImplicits$; | |
4: aload_0 | |
5: getfield #34; //Field evidence$15$mcI$sp:Lcom/azavea/math/Numeric; | |
8: invokevirtual #38; //Method com/azavea/math/EasyImplicits$.numeric$mIc$sp:(Lcom/azavea/math/Numeric;)Lcom/azavea/math/Numeric; | |
11: invokeinterface #44, 1; //InterfaceMethod com/azavea/math/Numeric.zero$mcI$sp:()I | |
16: invokestatic #50; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer; | |
19: invokeinterface #56, 2; //InterfaceMethod scala/Function1.apply:(Ljava/lang/Object;)Ljava/lang/Object; | |
24: areturn | |
public int blah2$mcI$sp(scala.Function1); | |
Code: | |
Stack=3, Locals=2, Args_size=2 | |
0: aload_1 | |
1: getstatic #32; //Field com/azavea/math/EasyImplicits$.MODULE$:Lcom/azavea/math/EasyImplicits$; | |
4: aload_0 | |
5: getfield #34; //Field evidence$15$mcI$sp:Lcom/azavea/math/Numeric; | |
8: invokevirtual #38; //Method com/azavea/math/EasyImplicits$.numeric$mIc$sp:(Lcom/azavea/math/Numeric;)Lcom/azavea/math/Numeric; | |
11: invokeinterface #44, 1; //InterfaceMethod com/azavea/math/Numeric.zero$mcI$sp:()I | |
16: invokeinterface #66, 2; //InterfaceMethod scala/Function1.apply$mcII$sp:(I)I | |
21: ireturn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment