Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible for the same javac compiler to compile the same set of source files but produce class files of different checksums?
    primarykey
    data
    text
    <p>I was attempting to compare the results of this: (in ant)</p> <pre><code> &lt;javac target="1.5" source="1.5" deprecation="on" fork="yes" optimize="true" debug="true" debuglevel="lines,vars,source"&gt; &lt;classpath&gt; &lt;fileset dir="${project.basedir}/../lib"&gt; &lt;include name="**/*.jar" /&gt; &lt;include name="**/*.zip" /&gt; &lt;/fileset&gt; &lt;/classpath&gt; &lt;/javac&gt; </code></pre> <p>...against this: (in maven)</p> <pre><code> &lt;plugin&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;2.3.2&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;compile&lt;/id&gt; &lt;phase&gt;compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;compile&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;target&gt;1.5&lt;/target&gt; &lt;source&gt;1.5&lt;/source&gt; &lt;debug&gt;true&lt;/debug&gt; &lt;debuglevel&gt;lines,vars,source&lt;/debuglevel&gt; &lt;showDeprecation&gt;true&lt;/showDeprecation&gt; &lt;optimize&gt;true&lt;/optimize&gt; &lt;fork&gt;true&lt;/fork&gt; &lt;includes&gt; ... &lt;/includes&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>...only to discover that 2 of the resulting class files have slightly different checksums, while the rest are identical. I consider multi-threading to have played a part, but the checksums produced for either option appear to be consistent upon repeated attempts. What can possibly account for this result? </p> <p><strong>Update:</strong></p> <p>I have examined one set of the files with different checksums using <code>javap -verbose</code> and noticed the only difference being:</p> <pre><code>const #16 = class #108; // java/lang/Exception const #17 = Method #102.#109; // java/io/Writer.close:()V const #18 = Method #7.#109; // java/io/FileWriter.close:()V </code></pre> <p>as opposed to:</p> <pre><code>const #16 = Method #102.#108; // java/io/Writer.close:()V const #17 = Method #7.#108; // java/io/FileWriter.close:()V const #18 = class #109; // java/lang/Exception </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.
 

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