Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suppose the information is stored in the "pickled" part of the <code>.class</code> file, according to the <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.214.5115&amp;rep=rep1&amp;type=pdf" rel="nofollow noreferrer">2008 "Reflecting Scala" rapport</a>, from Yohann Coppel, under the supervision of Prof. Martin Odersky.</p> <blockquote> <p>During the compilation process (represented on fig. 2), the Scala compiler generates two types of data. </p> <ul> <li>The first one is some classic Java bytecode, which can be read and executed by a standard Java virtual machine. </li> <li>The second one is what is called “Pickled data”, and represents the basic structure of the original source file.<br> This information is enclosed in a <code>.class</code> file.<br> The Java bytecode specification allows the compiler to “define and emit class files containing new attributes in the attributes tables of class file structures”. These attributes are silently ignored by JVMs if they do not recognize them.</li> </ul> </blockquote> <p><img src="https://i.stack.imgur.com/5C4zn.png" alt="Pickelr"></p> <blockquote> <p>The Scala compiler generates pickled data for about any data structure in a Scala program, called symbols in the pickler context.<br> Symbols are stored linearly with the format shown on Fig. 3.</p> </blockquote> <p><img src="https://i.stack.imgur.com/AucnY.png" alt="http://img27.i_mageshack.us/img27/4042/scalapickledformat.png"></p> <blockquote> <ul> <li>The tag represents the type of data stored, </li> <li>then the length gives the length of the following data block. </li> <li>The data block can contain multiple information, such as the name of a symbol.</li> </ul> </blockquote> <pre><code>ScalaSig = "ScalaSig" Version Symtab Version = Major_Nat Minor_Nat &lt;==== Symtab = numberOfEntries_Nat {Entry} </code></pre> <blockquote> <p>The ScalaSig attribute definition.<br> A more complete definition can be found in the <del><code>scala.tools.nsc.symtab.PickleFormat</code></del> source file (now <strong><a href="https://github.com/scala/scala/blob/2.12.x/src/reflect/scala/reflect/internal/pickling/PickleFormat.scala" rel="nofollow noreferrer"><code>scala.reflect.internal.pickling.PickleFormat</code></a></strong>).</p> </blockquote> <p>You can also see how to read the Pickled data in <strong><a href="http://www.assembla.com/code/scala-eclipse-toolchain/git/nodes/src/compiler/scala/tools/nsc/util/ShowPickled.scala?rev=68435481a4e670941801dce6537b34429ce9eab7" rel="nofollow noreferrer"><code>scala.tools.nsc.util.ShowPickled</code></a></strong>.</p> <hr> <p><a href="http://www.assembla.com/code/scala-eclipse-toolchain/git/nodes/tools/showPickled?rev=565a793c993c48cab37a279fda9f24743a1e4c16" rel="nofollow noreferrer">This page</a> shows a script (not tested) which will display the pickled data:</p> <pre><code>#!/bin/sh # # Shows the pickled scala data in a classfile. if [ $# == 0 ] ; then echo "Usage: $0 [--bare] [-cp classpath] &lt;class*&gt;" exit 1 fi TOOLSDIR=`dirname $0` CPOF="$TOOLSDIR/cpof" PACK="$TOOLSDIR/../build/pack/lib" QUICK="$TOOLSDIR/../build/quick/classes" STARR="$TOOLSDIR/../lib" CP="" if [ -f "${PACK}/scala-library.jar" ] ; then CP=`${TOOLSDIR}/packcp` elif [ -d "${QUICK}/library" ] ; then CP=`${TOOLSDIR}/quickcp` else CP=`${TOOLSDIR}/starrcp` fi if [ "$1" == "-cp" ] ; then shift CP="${1}:${CP}" shift fi java -cp "$CP" scala.tools.nsc.util.ShowPickled $* </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload