<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kevin&#039;s Life &#187; Mine</title>
	<atom:link href="http://blog.lckymn.com/category/it/software-development/mine/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lckymn.com</link>
	<description>IT, Java, Ubuntu, Linux</description>
	<lastBuildDate>Wed, 16 Jun 2010 14:08:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Catch-Up 01 May, 2010</title>
		<link>http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/</link>
		<comments>http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 19:04:16 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Fundamental]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Web Application Development]]></category>
		<category><![CDATA[Mine]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Ubuntu Linux]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[equals]]></category>
		<category><![CDATA[hashCode]]></category>
		<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Issue Tracking System]]></category>
		<category><![CDATA[Java Reflection]]></category>
		<category><![CDATA[javac]]></category>
		<category><![CDATA[JDK7]]></category>
		<category><![CDATA[Kevin]]></category>
		<category><![CDATA[M2Eclipse]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Maven2]]></category>
		<category><![CDATA[Objects]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Sonatype]]></category>
		<category><![CDATA[Spring MVC]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=496</guid>
		<description><![CDATA[<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
Some part of <a href="#3. Shadowing Declarations?">3.  Bug in Java compiler?Shadowing Declarations?</a> is <a href="#update1-2010-05-10">updated</a> <a href="#update2-2010-05-10">twice</a> on the 10th of May in 2010.
</div>
<p>I have been very busy and am still busy so haven&#8217;t written anything for quite a while on my blog except for those entries with only one or two sentences. So I&#8217;m quickly writing what I do these days and some issues I have <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/">Catch-Up 01 May, 2010</a>...]</p>]]></description>
			<content:encoded><![CDATA[<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
Some part of <a href="#3. Shadowing Declarations?">3. <span style="text-decoration: line-through;"> Bug in Java compiler?</span>Shadowing Declarations?</a> is <a href="#update1-2010-05-10">updated</a> <a href="#update2-2010-05-10">twice</a> on the 10th of May in 2010.
</div>
<p>I have been very busy and am still busy so haven&#8217;t written anything for quite a while on my blog except for those entries with only one or two sentences. So I&#8217;m quickly writing what I do these days and some issues I have dealt with.</p>
<h3><a name="1. Issue with the new m2eclipse (version: 0.10.0.20100209-0800)">1. Issue with the new m2eclipse (version: 0.10.0.20100209-0800)</a></h3>
<p><a href="http://www.sonatype.com/">Sonatype</a> released the new version of <a href="http://m2eclipse.sonatype.org/">m2eclipse</a> in February 2010. Since I updated with it, I had got some problem with maven build through <a href="http://hudson-ci.org/">Hudson</a>.</p>
<p>The new version of m2eclipse comes with maven3 embedded yet my server uses maven2 so does my Linux on my Desktop PC.  So it was only m2eclipse which uses maven3 (SNAPSHOT version) and I deployed some of my libraries used in one web application development project. Problem was that I deployed the dependency libraries several times with the same version number. With maven2, it&#8217;s OK as it uses time-stamp to distinguish one version from another within the same version, yet with maven3, having the same version is not allowed. Well, I am not 100% sure about this as once I solved the problem I didn&#8217;t really check the details as I didn&#8217;t have enough time. Anyway, so as shown in the following image, the project status icon once became dark rain clouds which mean really bad.<br />
<div id="attachment_501" class="wp-caption alignnone" style="width: 530px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure01.jpg" alt="Build Failure: Project status icon became dark rain clouds" title="00 build failure01" width="520" height="294" class="size-full wp-image-501" /></a><p class="wp-caption-text">Build Failure: Project status icon became dark rain clouds</p></div></p>
<p>My project build failed seven times due to the difference between maven2 and maven3 I described above, or it can be something else yet it is caused by some difference between those two versions.<br />
<div id="attachment_502" class="wp-caption alignnone" style="width: 336px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/00_build_failure02.jpg" alt="Build Failure: It failed seven times due to the difference between maven2 and maven3" title="00 build failure02" width="326" height="446" class="size-full wp-image-502" /></a><p class="wp-caption-text">Build Failure: It failed seven times due to the difference between maven2 and maven3</p></div><br />
(It happened in February. The build number in the image is 108 but it is now 305).</p>
<p>So why did I not just keep the old version of m2eclipse with maven2 embedded? Well, the old one comes with some old version of maven2 which does not support <a href="http://maven.apache.org/guides/mini/guide-encryption.html">password encryption</a> while the maven2 on both my PC and my server does support it as it is a newer version. Thus I updated with the new m2eclipse as soon as it was available yet didn&#8217;t really expect that it comes with maven3. Anyway, It&#8217;s solved by using maven2 installed on my PC when deploying project packages. The other times such as solving dependencies and building package without deployment, I can still use the embedded maven3 in the new m2eclipse without any problems.</p>
<h3><a name="2. I have been working on...">2. I have been working on&#8230;</a></h3>
<p>I founded a start-up company with my friend a few months ago, and we are currently working on a web application development for our own start-up, but it is probably too premature to announce what it is as it&#8217;s still an early stage of development.<br />
The issues listed in the following image is a part of the issues I and my colleague have solved and been working on.<br />
<div id="attachment_503" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_00.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_00.jpg" alt="I&#039;m currently working on this project." title="01 Issue Tracking 00" width="640" height="477" class="size-full wp-image-503" /></a><p class="wp-caption-text">I'm currently working on this project.</p></div></p>
<p>In addition, I have been developing my own Java libraries which can be commonly used in many other projects (and my friend has also been developing reusable JavaScript libraries). However, I did not record all the issues belong to these reusable components and recently felt that I should do it before I go any further. Otherwise, I may later forget what problems I solved and how I did as well as all the issues covered previously. So I wrote all the tickets for those libraries.<br />
<div id="attachment_504" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_01.jpg" alt="Issues of commonly used libraries built by myself" title="01 Issue Tracking 01" width="640" height="335" class="size-full wp-image-504" /></a><p class="wp-caption-text">Issues of commonly used libraries built by myself</p></div></p>
<p>I&#8217;ve also been developing &#8216;Java object to JSON&#8217; library and did the same as what I just explained (that is creating issue tickets).  There are already a number of the libraries which convert Java object into <a href="http://json.org/">JSON</a> so why would I make another?  Well, there can be several reasons but major ones are</p>
<ol>
<li>I need it to convert any <a href="http://en.wikipedia.org/wiki/POJO">POJO</a> with only <a href="http://en.wikipedia.org/wiki/Java_annotation">annotations</a> into <a href="http://json.org/">JSON</a>.</li>
<li>It has to be simple as I do not want to have any complex functions or heavy library for a simple conversion (some libraries are too heavy for such a simple task).</li>
<li>When customisation is required or bug is found in the library, I want to be able to change and fix it however I want so that I do not have to waste my time on waiting for others to solve it.</li>
<li>I want it to work in some environments where using bytecode manipulation is not an option. So if I programme one with bytecode manipulation then it works faster when it&#8217;s available whereas the other one is without it so that it can be used in those enviornments (I currently have only the latter one and will do the former one when I have time later).</li>
</ol>
<p>The following issues are what I have solved for the Java to JSON library.<br />
<div id="attachment_505" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_02.jpg" alt="Issues of my Java object to JSON library" title="01 Issue Tracking 02" width="640" height="451" class="size-full wp-image-505" /></a><p class="wp-caption-text">Issues of my Java object to JSON library</p></div></p>
<p>Finally, I have another project to help Ajax enabled web application development. From my experience, I found that it is sharing the information about the available server-side functions with the client-side developers that causes the most waste of time between the front-end development and the back-end development.  The first time one function is made or whenever the existing ones are changed, I have to write or rewrite the document explaining it and the client-side developer has to find the changed parts in the document.  It is annoying and a non-productive moment in the development so I and my colleague discussed about this issue and came up with the idea of having a library which exposes all the available server-side functions to the front-end (It can understand Spring <code>@MVC</code> controllers).  For now, it has only this, yet I will add more features to help Ajax web application development.<br />
<div id="attachment_506" class="wp-caption alignnone" style="width: 650px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_03.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/01_issueTracking_03.jpg" alt="Issues of my web method library" title="01 IssueTracking 03" width="640" height="146" class="size-full wp-image-506" /></a><p class="wp-caption-text">Issues of my web method library</p></div></p>
<p>* As I used more and more reflection to develop those libraries, I realised that Java Reflection has no method to get the names of method parameters. Well, there can be some ways for instance, using -g (generating debugging info) option when compiling or using some libraries such as <a href="http://asm.ow2.org/">ASM</a> or use <a href="http://paranamer.codehaus.org/">ParaNamer</a> (It requires an additional step when compiling to add the constants having the parameter names in the class) but not by just Java reflection.  Anyway, none of these is the solution I want, and unfortunately if I heard right, this problem will remain in JDK 7. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<h3><a name ="3. Shadowing Declarations?">3. <span style="text-decoration: line-through;">Bug in Java compiler?</span> Shadowing Declarations?</a></h3>
<p>I created the Objects utility class based on <a href="http://download.java.net/jdk7/docs/api/java/util/Objects.html">http://download.java.net/jdk7/docs/api/java/util/Objects.html</a>. This will be available in JDK 7 yet I wanted to use it before JDK 7 is released so I made my own one. I can use it now, and it can easily be replaced by the one in JDK when it&#8217;s available.  <span style="text-decoration: line-through;">After I made it, I found some weird bug, I believe, in Java compiler.</span> After I used it, I had some problem and though it could be a bug in Java compiler yet <a href="#update2-2010-05-10">it looks like &#8216;shadowing declarations&#8217;.</a></p>
<p>This is the part of Objects class I coded.</p>
<pre class="brush: java;">
package com.lckymn.kevin.common.util;

/**
 * @author Lee, SeongHyun (Kevin)
 * @version 0.0.1 (2010-04-30)
 */
public final class Objects
{
    private Objects()
    {
        throw new IllegalStateException(getClass().getName() + &quot; cannot be instantiated.&quot;);
    }

    // other code omitted ...

    /**
     * Returns the hash code of a non-{@code null} argument and 0 for a {@code null} argument.
     *
     * @param o
     *            an object
     * @return the hash code of a non-{@code null} argument and 0 for a {@code null} argument
     * @see {@link Object#hashCode()}
     */
    public static int hashCode(final Object o)
    {
        return (null == o ? 0 : o.hashCode());
    }

    // other code omitted ...
}
</pre>
<p>The following code is a POJO in which I want to use the Objects.hashCode(Object) method.</p>
<pre class="brush: java;">
package com.lckymn.kevin.test.bean;

/**
 * @author Lee, SeongHyun (Kevin)
 * @version 0.0.1 (2010-04-30)
 */
public class SomePojo
{
    private final int number;
    private final String name;

    public SomePojo(int number, String name)
    {
        this.number = number;
        this.name = name;
    }

    public int getNumber()
    {
        return number;
    }

    public String getName()
    {
        return name;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + number;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (!(obj instanceof SomePojo))
        {
            return false;
        }
        final SomePojo that = (SomePojo) obj;
        return (this.number == that.getNumber())
                &amp;&amp; (this.name == that.getName() ||
                        (null != this.name &amp;&amp; this.name.equals(that.getName())));
    }
}
</pre>
<p>So I changed this code snippet</p>
<pre class="brush: java; gutter: false; highlight: [7];">
@Override
public int hashCode()
{
    final int prime = 31;
    int result = 1;
    result = prime * result + number;
    result = prime * result + ((name == null) ? 0 : name.hashCode());
    return result;
}
</pre>
<p>to this.</p>
<pre class="brush: java; gutter: false; highlight: [3,15];">
package com.lckymn.kevin.test.bean;

import static com.lckymn.kevin.common.util.Objects.*;

public class SomePojo
{
    // ...

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + number;
        result = prime * result + hashCode(name);
        return result;
    }
}
</pre>
<p>I used static import and hashCode(Object) method in the Objects class. Although, nothing&#8217;s wrong in the code, my Eclipse complains that there is a compile-time error. The following image shows that.<br />
<div id="attachment_511" class="wp-caption alignnone" style="width: 929px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_01.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_01.jpg" alt="Objects.hashCode(Object) with static import does not work." title="02 Objects.hashCode 01" width="919" height="837" class="size-full wp-image-511" /></a><p class="wp-caption-text">Objects.hashCode(Object) with static import does not work.</p></div></p>
<p>Yet the same code with no-static import but using class name as the qualifier to use <code>hashCode(Object)</code> method works perfectly. The following code has <code>Objects.hashCode(name)</code> and no compile-time error.</p>
<pre class="brush: java; highlight: [36];">
package com.lckymn.kevin.test.bean;

import com.lckymn.kevin.common.util.Objects;

/**
 * @author Lee, SeongHyun (Kevin)
 * @version 0.0.1 (2010-04-30)
 */
public class SomePojo
{
    private final int number;
    private final String name;

    public SomePojo(int number, String name)
    {
        this.number = number;
        this.name = name;
    }

    public int getNumber()
    {
        return number;
    }

    public String getName()
    {
        return name;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + number;
        result = prime * result + Objects.hashCode(name);
        return result;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (this == obj)
        {
            return true;
        }
        if (null == obj)
        {
            return false;
        }
        if (!(obj instanceof SomePojo))
        {
            return false;
        }
        final SomePojo that = (SomePojo) obj;
        return (this.number == that.getNumber())
                &amp;&amp; (this.name == that.getName() || (null != this.name &amp;&amp; this.name.equals(that.getName())));
    }
}
</pre>
<p>The following image shows it has no error in the part where <code>Objects.hashCode(Object)</code> is used..<br />
<div id="attachment_508" class="wp-caption alignnone" style="width: 515px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_02.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/02_objects_hashcode_02.jpg" alt="Using Class as qualifier to use hashCode works." title="02 Objects.hashCode 02" width="505" height="622" class="size-full wp-image-508" /></a><p class="wp-caption-text">Using Class as qualifier to use hashCode works.</p></div></p>
<p>I wondered if it&#8217;s a bug in the Eclipse or a bug in the Java compiler. So I opened the terminal and tested it.</p>
<pre class="brush: bash; gutter: false;">
$ javac -version
javac 1.6.0_15

$ javac com/lckymn/kevin/test/bean/SomePojo.java
com/lckymn/kevin/test/bean/SomePojo.java:39: cannot find symbol
symbol  : method hashCode(java.lang.String)
location: class com.lckymn.kevin.test.bean.SomePojo
        result = prime * result + hashCode(name);
                                  ^
com/lckymn/kevin/test/bean/SomePojo.java:39: operator + cannot be applied to int,hashCode
        result = prime * result + hashCode(name);
                       ^
com/lckymn/kevin/test/bean/SomePojo.java:39: incompatible types
found   : &lt;nulltype&gt;
required: int
        result = prime * result + hashCode(name);
                                ^
3 errors
</pre>
<p>As it shows, the compiler does totally not understand that the hashCode(Object) method from the Objects class is available and valid.</p>
<p>Is a bug only in the SUN JDK in the Ubuntu Linux repository? So I tried with OpenJDK 6 as well.</p>
<pre class="brush: bash; gutter: false;">
$ /usr/lib/jvm/java-6-openjdk/bin/javac -version
javac 1.6.0_0

$ /usr/lib/jvm/java-6-openjdk/bin/javac com/lckymn/kevin/test/bean/SomePojo.java
com/lckymn/kevin/test/bean/SomePojo.java:39: cannot find symbol
symbol  : method hashCode(java.lang.String)
location: class com.lckymn.kevin.test.bean.SomePojo
        result = prime * result + hashCode(name);
                                  ^
com/lckymn/kevin/test/bean/SomePojo.java:39: operator + cannot be applied to int,hashCode
        result = prime * result + hashCode(name);
                       ^
com/lckymn/kevin/test/bean/SomePojo.java:39: incompatible types
found   : &lt;nulltype&gt;
required: int
        result = prime * result + hashCode(name);
                                ^
3 errors
</pre>
<p>The same result&#8230;</p>
<p>OK, it might be a bug in that particular version. Fortunately, the most recent version of SUN JDK 6 was released yesterday. It was officially released before (the 15th of April, 2010) yet the version managed by Ubuntu was not available before yesterday. So I installed it and tested it again with the Java compiler in the new JDK6.<br />
<div id="attachment_509" class="wp-caption alignnone" style="width: 622px"><a href="http://blog.lckymn.com/wp-content/uploads/2010/05/03_update_jdk.jpg"><img src="http://blog.lckymn.com/wp-content/uploads/2010/05/03_update_jdk.jpg" alt="New version of SUN JDK6 is available in the Ubuntu repository" title="03 Update JDK" width="612" height="640" class="size-full wp-image-509" /></a><p class="wp-caption-text">New version of SUN JDK6 is available in the Ubuntu repository</p></div></p>
<p>It still has the same problem.</p>
<pre class="brush: bash; gutter: false;">
$ javac -version
javac 1.6.0_20

$ javac com/lckymn/kevin/test/bean/SomePojo.java
com/lckymn/kevin/test/bean/SomePojo.java:39: cannot find symbol
symbol  : method hashCode(java.lang.String)
location: class com.lckymn.kevin.test.bean.SomePojo
        result = prime * result + hashCode(name);
                                  ^
com/lckymn/kevin/test/bean/SomePojo.java:39: operator + cannot be applied to int,hashCode
        result = prime * result + hashCode(name);
                       ^
com/lckymn/kevin/test/bean/SomePojo.java:39: incompatible types
found   : &lt;nulltype&gt;
required: int
        result = prime * result + hashCode(name);
                                ^
3 errors
</pre>
<p>I probably need to test with the Java compiler in the JDK6 for Windows but I have no stomach for that now nor do I have time to do that.</p>
<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
<a name="update1-2010-05-10">* Update1 (2010-05-10)</a><br />
I also tested it with the Java compiler in the JDK 6 (1.6.0_16) for Windows and got the same result. <span style="text-decoration: line-through">It seem like static import cannot handle method overloading. I didn&#8217;t have time to research to find the details but based on my testing, method overloading cannot be used with static import.<br />
If so then there should be a good reason for that, and the only one I can think of right now is that it might have something to do with varargs.</span><br />
Take a look at the following code.</p>
<pre class="brush: java;">
package com.lckymn.kevin.common.util;

public final class SomeHelper
{
    private SomeHelper()
    {
        throw new IllegalStateException(getClass().getName() + &quot; cannot be instantiated.&quot;);
    }

    public static void test(Object... object)
    {
        System.out.println(&quot;SomeHelper.test()&quot;);
    }
}
</pre>
<pre class="brush: java; highlight: [3,14,17];">
package com.lckymn.kevin.test;

import static com.lckymn.kevin.common.util.SomeHelper.test;

public class Test
{
    public void test()
    {
        System.out.println(&quot;Test.test()&quot;);
    }

    public void callTest()
    {
        test();            // no error here.

        Object object = new Object();
        test(object);    // compile-time error
    }
}
</pre>
<p><span style="text-decoration: line-through">Since a method with varargs can take no argument when it&#8217;s called, Test.test() and SomeHelper.test(Object&#8230; object) can be indistinguishable with static import. This is, I think, probably one of the reasons why method overloading is not allowed with static import. Nevertheless, it is still very weird as calling test() does not cause any compile-time error while test(object) does.</span><br />
So the following code has no compile-time error and displays <code>Test.test()</code>.</p>
<pre class="brush: java; highlight: [3];">
package com.lckymn.kevin.test;

import static com.lckymn.kevin.common.util.SomeHelper.test;

public class Test
{
    public void test()
    {
        System.out.println(&quot;Test.test()&quot;);
    }

    public void callTest()
    {
        test();    // static import of SomeHelper.test has no effect here.
    }

    public static void main(String[] args)
    {
        new Test().callTest();
        System.exit(0);
    }
}
</pre>
<p>It displays <code>Test.test()</code>.</p>
<p>What if the helper class has test() method with no arguments and the Test class has test() method with varargs then call <code>test()</code>? The same result! It still calls Test&#8217;s test() method with varargs (<code>Test.test(Object... object)</code>).</p>
<pre class="brush: java; highlight: [10];">
package com.lckymn.kevin.common.util;

public final class SomeHelper
{
    private SomeHelper()
    {
        throw new IllegalStateException(getClass().getName() + &quot; cannot be instantiated.&quot;);
    }

    public static void test()
    {
        System.out.println(&quot;SomeHelper.test()&quot;);
    }
}
</pre>
<pre class="brush: java; highlight: [3,7];">
package com.lckymn.kevin.test;

import static com.lckymn.kevin.common.util.SomeHelper.test;

public class Test
{
    public void test(Object... object)
    {
        System.out.println(&quot;Test.test(Object...object)&quot;);
    }

    public void callTest()
    {
        test(); // it calls the Test.test(Object... object) method NOT SomeHelper.test().
    }

    public static void main(String[] args)
    {
        new Test().callTest();
        System.exit(0);
    }
}
</pre>
<p>It displays <code>Test.test(Object...object)</code>
</div>
<div class="txc-textbox" style="border: 3px solid rgb(243, 197, 52); padding: 10px; background-color: rgb(254, 254, 184);">
<a name="update2-2010-05-10">Update2 (2010-05-10)</a><br />
It is more likely to be <a href="http://java.sun.com/docs/books/jls/third_edition/html/names.html#34133">&#8216;Shadowing Declarations&#8217;</a>. Although, I couldn&#8217;t find the exactly matching case from the <a href="http://java.sun.com/docs/books/jls/">JLS</a> yet, it makes more sense if the method imported by static-import is shadowed.
</div>
<h3><a name="4. Using Objects">4. Using Objects</a></h3>
<p>By the way, the Objects class is simple but very useful.<br />
with it, the highlighted parts of the following code can</p>
<pre class="brush: java; highlight: [53,54,55,56,57,72,73,74,75];">
package com.lckymn.kevin.test.bean;

public class Bank
{
    private Long id;
    private String bankName;
    private String bsbNumber;
    private String address;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getBankName()
    {
        return bankName;
    }

    public void setBankName(String bankName)
    {
        this.bankName = bankName;
    }

    public String getBsbNumber()
    {
        return bsbNumber;
    }

    public void setBsbNumber(String bsbNumber)
    {
        this.bsbNumber = bsbNumber;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    @Override
    public int hashCode()
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((bankName == null) ? 0 : bankName.hashCode());
        result = prime * result + ((bsbNumber == null) ? 0 : bsbNumber.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object bank)
    {
        if (this == bank)
        {
            return true;
        }
        if (!(bank instanceof Bank))
        {
            return false;
        }
        final Bank that = (Bank) bank;
        return (this.bankName == that.getBankName() ||
               (null != this.bankName &amp;&amp; this.bankName.equals(that.getBankName())))
                &amp;&amp; (this.bsbNumber == that.getBsbNumber() ||
                   (null != this.bsbNumber &amp;&amp; this.bsbNumber.equals(that.getBsbNumber())));
    }
}
</pre>
<p>become like this</p>
<pre class="brush: java; highlight: [55,70,71];">
package com.lckymn.kevin.test.bean;

import com.lckymn.kevin.common.util.Objects;

public class Bank
{
    private Long id;
    private String bankName;
    private String bsbNumber;
    private String address;

    public Long getId()
    {
        return id;
    }

    public void setId(Long id)
    {
        this.id = id;
    }

    public String getBankName()
    {
        return bankName;
    }

    public void setBankName(String bankName)
    {
        this.bankName = bankName;
    }

    public String getBsbNumber()
    {
        return bsbNumber;
    }

    public void setBsbNumber(String bsbNumber)
    {
        this.bsbNumber = bsbNumber;
    }

    public String getAddress()
    {
        return address;
    }

    public void setAddress(String address)
    {
        this.address = address;
    }

    @Override
    public int hashCode()
    {
        return Objects.hash(bankName, bankName);
    }

    @Override
    public boolean equals(Object bank)
    {
        if (this == bank)
        {
            return true;
        }
        if (!(bank instanceof Bank))
        {
            return false;
        }
        final Bank that = (Bank) bank;
        return Objects.equals(this.bankName, that.getBankName())
               &amp;&amp; Objects.equals(this.bsbNumber, that.getBsbNumber());
    }
}
</pre>
<p>So these five lines in the hashCode method</p>
<pre class="brush: java; gutter: false;">
final int prime = 31;
int result = 1;
result = prime * result + ((bankName == null) ? 0 : bankName.hashCode());
result = prime * result + ((bsbNumber == null) ? 0 : bsbNumber.hashCode());
return result;
</pre>
<p>become</p>
<pre class="brush: java; gutter: false;">
return Objects.hash(bankName, bankName);
</pre>
<p>and these four lines in the equals method</p>
<pre class="brush: java; gutter: false;">
return (this.bankName == that.getBankName() ||
       (null != this.bankName &amp;&amp; this.bankName.equals(that.getBankName())))
        &amp;&amp; (this.bsbNumber == that.getBsbNumber() ||
           (null != this.bsbNumber &amp;&amp; this.bsbNumber.equals(that.getBsbNumber())));
</pre>
<p>become</p>
<pre class="brush: java; gutter: false;">
return Objects.equals(this.bankName, that.getBankName())
       &amp;&amp; Objects.equals(this.bsbNumber, that.getBsbNumber());
</pre>
<p>Although one might say that I can use <a href="http://projectlombok.org/">Lombok</a> instead, I prefer to see what is going on in my code. Those hashCode and equals methods are not additional info of the class. It tells what makes instances of the class equal thus I prefer to have it in there to see and want to freely change it whenever and however I want. Well, in other words, just a matter of personal preference. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
That&#8217;s it.<br />
I perhaps have more to say yet am getting tired (4:55 AM :O). So I&#8217;m calling it a night. <img src='http://blog.lckymn.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2010/05/01/catch-up-2010-05-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Communication with Users</title>
		<link>http://blog.lckymn.com/2009/05/14/communication-with-users/</link>
		<comments>http://blog.lckymn.com/2009/05/14/communication-with-users/#comments</comments>
		<pubDate>Thu, 14 May 2009 10:52:45 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Mine]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[TeCTra]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Communication]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Feedback]]></category>
		<category><![CDATA[Issue Tracking]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[User]]></category>

		<guid isPermaLink="false">http://blog.lckymn.com/?p=137</guid>
		<description><![CDATA[<p>I have developed Team Contribution Tracking (TeCTra) system for UTS. It is an Ajax web application the back-end of which is built using Java.  A few months ago, a new function to get feedback from users was added to TeCTra.</p>
<div id="attachment_138" class="wp-caption aligncenter" style="width: 547px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_function.jpg"><img class="size-full wp-image-138" title="TeCTra User Feedback Function" src="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_function.jpg" alt="TeCTra User Feedback Function" width="537" height="81" /></a><p class="wp-caption-text">TeCTra User Feedback Function</p></div>
<p>About a half month ago, I&#8217;ve got a feedback email from a user.  This is sent <p style="border: 3px solid rgb(243, 197, 52); padding: 5px; background-color: rgb(254, 254, 184); width: 600px; text-align: center;">[...Continue reading <a href="http://blog.lckymn.com/2009/05/14/communication-with-users/">Communication with Users</a>...]</p>]]></description>
			<content:encoded><![CDATA[<p>I have developed Team Contribution Tracking (TeCTra) system for UTS. It is an Ajax web application the back-end of which is built using Java.  A few months ago, a new function to get feedback from users was added to TeCTra.</p>
<div id="attachment_138" class="wp-caption aligncenter" style="width: 547px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_function.jpg"><img class="size-full wp-image-138" title="TeCTra User Feedback Function" src="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_function.jpg" alt="TeCTra User Feedback Function" width="537" height="81" /></a><p class="wp-caption-text">TeCTra User Feedback Function</p></div>
<p>About a half month ago, I&#8217;ve got a feedback email from a user.  This is sent through the function above.</p>
<div id="attachment_140" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_01.jpg"><img class="size-full wp-image-140" title="TeCTra User Feedback 01" src="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_01.jpg" alt="TeCTra User Feedback Email" width="300" height="250" /></a><p class="wp-caption-text">TeCTra User Feedback Email</p></div>
<div id="attachment_141" class="wp-caption aligncenter" style="width: 396px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_02.jpg"><img class="size-full wp-image-141" title="TeCTra User Feedback 02" src="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra_user_feedback_02.jpg" alt="TeCTra User Feedback Email" width="386" height="192" /></a><p class="wp-caption-text">TeCTra User Feedback Email</p></div>
<p>This feedback is about the usability of TeCTra. What he/she points out is that the button to create a new task in the time sheet tab is positioned too close to the remove button so users may click the remove button by mistake when they want to click the add task button.<br />
As the image below shows, the last remove button is too close to the new task button.  So as mentioned in the feedback, users might click the remove button by mistake.</p>
<div id="attachment_143" class="wp-caption aligncenter" style="width: 850px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra-old-remove_task_and_new_task.jpg"><img class="size-full wp-image-143" title="TeCTra - Old Remove Task Buttons and New Task Button" src="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra-old-remove_task_and_new_task.jpg" alt="The last remove task button is too close to the new task button." width="840" height="624" /></a><p class="wp-caption-text">The last remove task button is too close to the new task button.</p></div>
<p>We, the development team of the TeCTra, had a discussion about this and other issues then decided to move the buttons to the right-hand side. Since the front-end is developed by my friend, Sverre, he changed the positions of the remove buttons.  My boss, Dr. Richard Raban, also brought other issues so I and my friend took care of all of these and deployed a new version of TeCTra.</p>
<div id="attachment_144" class="wp-caption aligncenter" style="width: 785px"><a href="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra-new-remove_task_and_new_task.jpg"><img class="size-full wp-image-144" title="TeCTra - New Remove Task Buttons and New Task Button" src="http://blog.lckymn.com/wp-content/uploads/2009/05/tectra-new-remove_task_and_new_task.jpg" alt="Now the remove buttons are all right-justified so users will not click it by chance when they want to click the new task button." width="775" height="548" /></a><p class="wp-caption-text">Now the remove buttons are all right-justified so users will not click it by chance when they want to click the new task button.</p></div>
<p>It is good to have an issue tracking system so that the users of software can easily report bugs they found or require new functions they want.  This might be good enough yet it is even better if the application itself has issue tracking and feedback functions as I&#8217;ve learned from the user feedback function.  Thus I am thinking to implement feedback and bug reporting functions which directly add a new ticket to an issue tracking system from my next application development.  So it does not only send a feedback email to the developer but also add an issue to the issue tracking system.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lckymn.com/2009/05/14/communication-with-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
