[trend_fp] RE: [trend_fp] 類似constructor的行為

  • From: "shannon_chuang@xxxxxxxxxxxx" <shannon_chuang@xxxxxxxxxxxx>
  • To: "trend_fp@xxxxxxxxxxxxx" <trend_fp@xxxxxxxxxxxxx>, "leo_chung@xxxxxxxxxxxx" <leo_chung@xxxxxxxxxxxx>
  • Date: Fri, 8 May 2015 07:11:32 +0000

Mike反組譯的Java code看到個有趣的東西耶

”ScalaSignature”

查了一下,Scala會把class的資訊存在signature裡面耶。
Leo剛才有發現不能直接用java去跑scala compile出來的class,我猜就是因為這個原因。

http://www.scala-lang.org/old/sites/default/files/sids/dubochet/Mon,%202010-05-31,%2015:25/Storage%20of%20pickled%20Scala%20signatures%20in%20class%20files.pdf
What are pickled Scala signatures?
Pickled Scala signatures are compressed representations of the interfaces of
Scala entities — classes, traits and objects.

The Java class file format itself can only represent Scala entities as
simplified Java-like classes. This is sufficient for the
JVM to run Scala programs. Other tools require full Scala signatures. For
example, the compiler requires for type checking
the full signatures of referenced libraries. You can get an idea of the
information contained in class files and in pickled Scala
signatures by decompiling class files of Scala programs using javap and scalap
respectively.

The interface constructed during compilation of the original source file is
compressed by the Scala pickler into a very efficient
binary representation. This is then attached to class files using the method
described below. Normal Java tools do not recognize
this information, but Scala-specific tools can use it to retrieve full
signatures.

-Shannon

From: trend_fp-bounce@xxxxxxxxxxxxx [mailto:trend_fp-bounce@xxxxxxxxxxxxx] On
Behalf Of ???
Sent: Friday, May 08, 2015 2:55 PM
To: trend_fp@xxxxxxxxxxxxx
Subject: [trend_fp] 類似constructor的行為

找了一個比較強的反組譯器
初步小實驗
他把println 放在constructor中


class Hello{
println("test")
def mainx =
{
println("Hello ")
}

}
[內置圖片 1]

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

<table class="TM_EMAIL_NOTICE"><tr><td><pre>
TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential
and may be subject to copyright or other intellectual property protection.
If you are not the intended recipient, you are not authorized to use or
disclose this information, and we request that you notify us by reply mail or
telephone and delete the original message from your mail system.
</pre></td></tr></table>

PNG image

Other related posts:

  • » [trend_fp] RE: [trend_fp] 類似constructor的行為 - shannon_chuang@xxxxxxxxxxxx