Created
April 17, 2016 15:55
-
-
Save runarorama/df1d9c27b8aa25487907230d409f47b3 to your computer and use it in GitHub Desktop.
Decompiling a lazy val
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
/tmp ❯❯❯ cat Test.scala | |
class Something { | |
lazy val foo = getFoo | |
def getFoo = "foo!" | |
} | |
/tmp ❯❯❯ scalac Test.scala | |
/tmp ❯❯❯ procyon-decompiler Something.class | |
import scala.runtime.BoxedUnit; | |
import scala.reflect.ScalaSignature; | |
// | |
// Decompiled by Procyon v0.5.30 | |
// | |
@ScalaSignature(bytes = "\u0006\u0001\u00012A!\u0001\u0002\u0001\u000b\tI1k\\7fi\"Lgn\u001a\u0006\u0002\u0007\u00059A(Z7qift4\u0001A\n\u0003\u0001\u0019\u0001\"a\u0002\u0006\u000e\u0003!Q\u0011!C\u0001\u0006g\u000e\fG.Y\u0005\u0003\u0017!\u0011a!\u00118z%\u00164\u0007\"B\u0007\u0001\t\u0003q\u0011A\u0002\u001fj]&$h\bF\u0001\u0010!\t\u0001\u0002!D\u0001\u0003\u0011!\u0011\u0002\u0001#b\u0001\n\u0003\u0019\u0012a\u00014p_V\tA\u0003\u0005\u0002\u001655\taC\u0003\u0002\u00181\u0005!A.\u00198h\u0015\u0005I\u0012\u0001\u00026bm\u0006L!a\u0007\f\u0003\rM#(/\u001b8h\u0011!i\u0002\u0001#A!B\u0013!\u0012\u0001\u00024p_\u0002BQa\b\u0001\u0005\u0002M\taaZ3u\r>|\u0007") | |
public class Something | |
{ | |
private String foo; | |
private volatile boolean bitmap$0; | |
private String foo$lzycompute() { | |
synchronized (this) { | |
if (!this.bitmap$0) { | |
this.foo = this.getFoo(); | |
this.bitmap$0 = true; | |
} | |
final BoxedUnit unit = BoxedUnit.UNIT; | |
return this.foo; | |
} | |
} | |
public String foo() { | |
return this.bitmap$0 ? this.foo : this.foo$lzycompute(); | |
} | |
public String getFoo() { | |
return "foo!"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment