Scala の trait を解剖してみた
trait Trait {
val value: String = s"$getOne"
def getOne: Int = 1
def getTwo: Int
}
これを jad すると
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: Trait.scala
import scala.Predef$;
import scala.StringContext;
import scala.runtime.BoxesRunTime;
public abstract class Trait$class
{
public static int getOne(Trait $this)
{
return 1;
}
public static void $init$(Trait $this)
{
$this.Trait$_setter_$value_$eq((new StringContext(Predef$.MODULE$.wrapRefArray((Object[])(new String[] {
", "
})))).s(Predef$.MODULE$.genericWrapArray(((Object) (new Object[] {
BoxesRunTime.boxToInteger($this.getOne())
})))));
}
}
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: Trait.scala
public interface Trait
{
public abstract void Trait$_setter_$value_$eq(String s);
public abstract String value();
public abstract int getOne();
public abstract int getTwo();
}
こうなりました
String Interpolation については以下のスライドが詳しいです
Pinned Articles
About
ウェブ界隈でエンジニアとして労働活動に励んでいる @gomi_ningen 個人のブログです
Tags
LLM
promptfoo
GenAI
JavaScript
PowerShell
fluentd
kibana
elasticsearch
nginx
村川梨衣
五十嵐裕美
イベント
logrotate
IoT
Scala
Java
ICMP
iputils
C言語
WUG
mastodon
Swift
AWS
Windows
Clock
PoEAA
アーキテクチャ
iOS
DeviceFarm
プログラミング言語
OS
StepFunctions
Lambda
Serverless
terraform
ポエム
RHEL
ネットワーク
GraphQL
CloudWatch
Linux
Coreutils
nc
network
telnet
LinuxKernel
fpinscala
ELB
IAM
AppSync