Skip to content

Instantly share code, notes, and snippets.

@shinobu-aoki
Created February 9, 2012 15:34
Show Gist options
  • Save shinobu-aoki/1780692 to your computer and use it in GitHub Desktop.
Save shinobu-aoki/1780692 to your computer and use it in GitHub Desktop.
scalaのfinal valをコンパイルしてJava Decompilerで逆コンパイルしてみた
// finalVal.scalaをscalacしてJava Decompilerで逆コンパイルした結果
// http://java.decompiler.free.fr/
import scala.ScalaObject;
import scala.collection.mutable.StringBuilder;
import scala.reflect.ScalaSignature;
@ScalaSignature(bytes="\006\001e2A!\001\002\001\013\tAa)\0338bYZ\013GNC\001\004\003\035aT-\0349usz\032\001aE\002\001\r9\001\"a\002\007\016\003!Q!!\003\006\002\t1\fgn\032\006\002\027\005!!.\031<b\023\ti\001B\001\004PE*,7\r\036\t\003\037Ii\021\001\005\006\002#\005)1oY1mC&\0211\003\005\002\f'\016\fG.Y(cU\026\034G\017C\003\026\001\021\005a#\001\004=S:LGO\020\013\002/A\021\001\004A\007\002\005!9!\004\001b\001\n\013Y\022A\0014w+\005ar\"A\017\"\003y\tA!\0312dI\"1\001\005\001Q\001\016q\t1A\032<!\021\035\021\003A1A\005\002\r\n!A^\031\026\003\021\002\"aB\023\n\005\031B!AB*ue&tw\r\003\004)\001\001\006I\001J\001\004mF\002\003b\002\026\001\005\004%\taI\001\003mJBa\001\f\001!\002\023!\023a\001<3A!9a\006\001b\001\n\003\031\023A\001<4\021\031\001\004\001)A\005I\005\031ao\r\021\t\017I\002!\031!C\001G\005\021a\017\016\005\007i\001\001\013\021\002\023\002\007Y$\004\005C\0047\001\t\007I\021A\022\002\005Y,\004B\002\035\001A\003%A%A\002wk\001\002")
public class FinalVal
implements ScalaObject
{
private final String fv;
private final String v1 = "abcd";
private final String v2 = v1();
private final String v3 = "abcd";
private final String v4 = v3();
private final String v5 = new StringBuilder().append(v4()).append("abcd").toString();
public final String fv()
{
return "abcd"; }
public String v1() { return this.v1; }
public String v2() { return this.v2; }
public String v3() { return this.v3; }
public String v4() { return this.v4; }
public String v5() { return this.v5;
}
}
class FinalVal {
final val fv = "abcd"
val v1 = fv
val v2 = v1
val v3 = "abcd"
val v4 = v3
val v5 = v4 + fv
}
val finalVal = new FinalVal()
val clazz = classOf[FinalVal]
clazz.getDeclaredMethods.foreach { f =>
f.setAccessible(true)
println(f.getName + ":" + f.get(finalVal))
}
/*
fv:null
v1:abcd
v2:abcd
v3:abcd
v4:abcd
v5:abcdabcd
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment