[trend_fp] class and object的反組譯結果

  • From: 方鍾豪 <mike1026915.cs96@xxxxxxxxxxxxxx>
  • To: trend_fp@xxxxxxxxxxxxx
  • Date: Fri, 15 May 2015 12:49:56 +0800

Account.scala
class Account
{
var class_id = "1234567"
def print_account() = { println(Account.object_id)}
}

object Account
{
//def print_account() = { println(Account.class_id)} cannot access class
Account' s class_ud
var object_id = "7654321"
}

編譯之後生出兩個class

Account.class
import scala.Predef$;

public class Account
{

public static void object_id_$eq(String s)
{
Account$.MODULE$.object_id_$eq(s);
}

public static String object_id()
{
return Account$.MODULE$.object_id();
}

public String class_id()
{
return class_id;
}

public void class_id_$eq(String x$1)
{
class_id = x$1;
}

public void print_account()
{
Predef$.MODULE$.println(Account$.MODULE$.object_id());
}
public Account()
{
class_id = "1234567";
}

private String class_id;
}

Account$.class -> object Account
public final class Account$
{

public String object_id()
{
return object_id;
}

public void object_id_$eq(String x$1)
{
object_id = x$1;
}

private Account$()
{
object_id = "7654321";
}

public static final Account$ MODULE$ = this;
private String object_id;

static
{
new Account$();
}
}

Mike

--
*方鍾豪 (Mike Fang)*
Pervasive Embedded Technology Lab
Department of Computer Science, National Chiao Tung University

Other related posts:

  • » [trend_fp] class and object的反組譯結果 - 方鍾豪