<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Java on Code Log</title><link>https://codelog.me/en/categories/java/</link><description>Recent content in Java on Code Log</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 13 Sep 2015 22:32:31 +0800</lastBuildDate><atom:link href="https://codelog.me/en/categories/java/index.xml" rel="self" type="application/rss+xml"/><item><title>The Implementation Details of hashCode()</title><link>https://codelog.me/en/posts/java-hashcode/</link><pubDate>Sun, 13 Sep 2015 22:32:31 +0800</pubDate><guid>https://codelog.me/en/posts/java-hashcode/</guid><description>&lt;img src="https://codelog.me/img/2015-09-13-about-hashcode/658px-Setzkasten.jpg"&gt;
&lt;p&gt;&lt;em&gt;Image source:&lt;/em&gt;&lt;a href="https://commons.wikimedia.org/wiki/File:Setzkasten.jpg"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;</description></item><item><title>The Real Value of an int Variable Starting with 0 in Java</title><link>https://codelog.me/en/posts/java-octal-int/</link><pubDate>Tue, 10 Mar 2015 17:54:32 +0800</pubDate><guid>https://codelog.me/en/posts/java-octal-int/</guid><description>&lt;p&gt;Today, while solving a problem on LeetCode, I accidentally discovered the following issue:&lt;/p&gt;
&lt;p&gt;What value does the following Java statement output?&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;System.&lt;span style="color:#a6e22e"&gt;out&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;println&lt;/span&gt;(00123);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;System.&lt;span style="color:#a6e22e"&gt;out&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;println&lt;/span&gt;(0_123);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The answer is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;83
83
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>Understanding the Java String.intern() Memory Model</title><link>https://codelog.me/en/posts/java-string-intern/</link><pubDate>Tue, 20 Jan 2015 14:05:51 +0800</pubDate><guid>https://codelog.me/en/posts/java-string-intern/</guid><description>&lt;p&gt;As you know, calling &lt;code&gt;string.intern()&lt;/code&gt; in Java first looks up the corresponding string in the string constant pool; if the string does not exist, it is created in the pool and then returned.&lt;/p&gt;
&lt;p&gt;The string constant pool is a fixed-size HashMap whose default bucket count is 1009; starting from Java 7u40, this default was increased to 60013. In Java 6, the string constant pool was located in the Perm space, and starting from Java 7 it was moved to the Heap space. Below, we use a test program to look at the memory allocation of the string constant pool under the two different versions, Java 6 and Java 7.&lt;/p&gt;</description></item><item><title>JBoss AS7 Class Loading Mechanism</title><link>https://codelog.me/en/posts/class-loading-in-as7/</link><pubDate>Thu, 15 Jan 2015 11:05:51 +0800</pubDate><guid>https://codelog.me/en/posts/class-loading-in-as7/</guid><description>&lt;p&gt;Compared to earlier JBoss versions, AS7&amp;rsquo;s class loading mechanism is entirely different. AS7&amp;rsquo;s class loading is designed around JBoss modules. For an introduction to JBoss modules, see the previous article &lt;a href="http://m.com" title="JBoss Module Introduction"&gt;JBoss Module Introduction&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id="implicit-module-dependencies"&gt;Implicit module dependencies&lt;/h1&gt;
&lt;p&gt;When you deploy an application to a JBoss container, some dependencies are loaded implicitly. For example, if you deploy a Java EE application that contains EJBs, since EJBs need the &lt;code&gt;Javax.ejb.*&lt;/code&gt; package and other Java EE API related packages, the JARs containing those packages are already packaged into modules and included in the container by default as part of JBoss AS, so the modules for those JARs are loaded automatically.&lt;/p&gt;
&lt;p&gt;So when are implicit module dependencies loaded? When an application is deployed to the container, it passes through a chain called the &amp;ldquo;deployment processors&amp;rdquo;. Each processor on this chain has a method to detect whether the application needs certain modules to be loaded implicitly, and if so, loads the relevant dependencies.&lt;/p&gt;</description></item><item><title>JBoss AS7 Module Introduction</title><link>https://codelog.me/en/posts/jboss-as7-module/</link><pubDate>Tue, 13 Jan 2015 16:27:00 +0800</pubDate><guid>https://codelog.me/en/posts/jboss-as7-module/</guid><description>&lt;p&gt;Compared to earlier JBoss versions, AS7&amp;rsquo;s class loading mechanism is entirely different. AS7&amp;rsquo;s class loading is designed around JBoss modules.&lt;/p&gt;
&lt;h1 id="what-is-a-module"&gt;What is a module&lt;/h1&gt;
&lt;p&gt;A module is a collection of classes and resources, and each module corresponds to a class loader. Modules can have dependencies on one another: if a JAR in one module needs to use classes from a JAR in another module, the dependency must be declared explicitly; otherwise the modules are invisible to each other. Likewise, if you deploy an application to a JBoss AS7 container and the application depends on modules, those dependencies must also be declared explicitly.&lt;/p&gt;
&lt;p&gt;If you want to understand the JBoss AS7 module loading mechanism in depth, see: &lt;a href="http://jaxenter.com/inside-the-jboss-as-7modularity-107386.html" title="JBoss Module Analysis"&gt;JBoss Module Analysis&lt;/a&gt;&lt;/p&gt;
&lt;h1 id="benefits-of-modules"&gt;Benefits of modules&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;JARs of the same version are not loaded repeatedly.&lt;/li&gt;
&lt;li&gt;Avoids JAR version conflicts.&lt;/li&gt;
&lt;li&gt;Provides a more efficient class loading mechanism.&lt;/li&gt;
&lt;/ol&gt;</description></item></channel></rss>