<?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>Kai Witte's Blog</title>
	<atom:link href="http://witte-consulting.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://witte-consulting.com/blog</link>
	<description>Brief articles by Kai Witte</description>
	<lastBuildDate>Tue, 26 Jul 2011 09:58:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>List type mapping in Java</title>
		<link>http://witte-consulting.com/blog/list-type-mapping-in-java/</link>
		<comments>http://witte-consulting.com/blog/list-type-mapping-in-java/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 01:23:03 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=292</guid>
		<description><![CDATA[Recently someone asked me how to convert a List of type X to a List of type Y, given a well-defined function from X to Y. I&#8217;ve seen some horrible &#8220;solutions&#8221; for that in real world programs, and I hope that some people will benefit from my way of doing this: /** * Defines a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently someone asked me how to convert a List of type X to a List of type Y, given a well-defined function from X to Y. I&#8217;ve seen some horrible &#8220;solutions&#8221; for that in real world programs, and I hope that some people will benefit from my way of doing this:</p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #666666; font-style: italic;">/**
 * Defines a Function from E to F.
 * @param &lt;E&gt; the domain
 * @param &lt;F&gt; the codomain
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Converter<span style="color: #339933;">&lt;</span>E,F<span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#123;</span>
    F convert<span style="color: #009900;">&#40;</span>E f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #666666; font-style: italic;">/**
 * Maps a List of one type to a List of another type.
 * @param c the function used to convert from type E to type F
 * @param list the List to be mapped
 * @param &lt;E&gt; the domain
 * @param &lt;F&gt; the codomain
 * @return a new List with the elements mapped
 * @throws NullPointerException iff any argument is &lt;code&gt;null&lt;/code&gt;
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #339933;">&lt;</span>E,F<span style="color: #339933;">&gt;</span> List<span style="color: #339933;">&lt;</span>F<span style="color: #339933;">&gt;</span> map<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> Converter<span style="color: #339933;">&lt;</span>E,F<span style="color: #339933;">&gt;</span> c, <span style="color: #000000; font-weight: bold;">final</span> List<span style="color: #339933;">&lt;</span>E<span style="color: #339933;">&gt;</span> list<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> list <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// fail early; particularly important when using lazy evaluation</span>
        <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">NullPointerException</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> AbstractList<span style="color: #339933;">&lt;</span>F<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> F get<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> index<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> c.<span style="color: #006633;">convert</span><span style="color: #009900;">&#40;</span>list.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> size<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> list.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is some pretty generic code that can be used in many situations. For example in web applications it&#8217;s often necessary to map a certain entity to a String representation to display on the page.</p>
<p>Here is a usage example:</p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #000000; font-weight: bold;">final</span> List<span style="color: #339933;">&lt;</span>JFrame<span style="color: #339933;">&gt;</span> frames <span style="color: #339933;">=</span> <span style="color: #003399;">Arrays</span>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JFrame</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JFrame</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;world&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">final</span> List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> titles <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Converter<span style="color: #339933;">&lt;</span>JFrame, String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> convert<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">JFrame</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> f.<span style="color: #006633;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>,
        frames
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>titles<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// prints: [hello, world]</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">final</span> List<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span> nums <span style="color: #339933;">=</span> <span style="color: #003399;">Arrays</span>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">final</span> List<span style="color: #339933;">&lt;</span>Integer<span style="color: #339933;">&gt;</span> inc <span style="color: #339933;">=</span> map<span style="color: #009900;">&#40;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Converter<span style="color: #339933;">&lt;</span>Integer, Integer<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Integer</span> convert<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Integer</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> f <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>,
        nums
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>inc<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// prints: [2, 3, 4]</span></pre></div></div>

<p>Not as sweet as it would look like in a functional programming language like Haskell or Scala, but as good as it gets in Java.</p>
<p>See also:</p>
<ul>
<li><a href="http://functionaljava.org/">Functional Java</a> provides a more pure approach, using its own List implementation rather than <code>java.util.List</code></li>
<li><strong>Jushua Bloch. Effective Java, 2nd Edition. Chapter 4, Item 18</strong> provides a similar application of AbstractList</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/list-type-mapping-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The history of JTiger</title>
		<link>http://witte-consulting.com/blog/the-history-of-jtiger/</link>
		<comments>http://witte-consulting.com/blog/the-history-of-jtiger/#comments</comments>
		<pubDate>Sat, 22 May 2010 11:20:00 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=222</guid>
		<description><![CDATA[JTiger is a test framework, developed by Tony Morris in 2004 and published March 23, 2005. Defining attributes JTiger had a rich set of features and predefined assertions: It was easy to run tests programmatically or from an Apache Ant task. History Tony Morris developed Assertion Extensions for JUnit (at that time known as JUnitX; [...]]]></description>
			<content:encoded><![CDATA[<p>JTiger is a test framework, developed by <a href="http://cv.tmorris.net/">Tony Morris</a> in 2004 and published March 23, 2005.</p>
<h2>Defining attributes</h2>
<p>JTiger had a rich set of features and predefined assertions:<br />
<div class="wp-caption alignnone" style="width: 331px"><img alt="an integrated test assertion for serializability" src="http://kaiwitte.org/images/testcase1.png" title="JTiger testcase" width="321" height="113" /><p class="wp-caption-text">an integrated test assertion for serializability</p></div><br />
<div class="wp-caption alignnone" style="width: 331px"><img alt="check for expected Exception" src="http://kaiwitte.org/images/testcase2.png" title="check for expected Exception" width="321" height="113" /><p class="wp-caption-text">check for expected Exception</p></div><br />
<div class="wp-caption alignnone" style="width: 331px"><img style="max-width:200%" alt="check for equals/hashCode contract" src="http://kaiwitte.org/images/testcase3.png" title="assert correct serialization" width="664" height="130" /><p class="wp-caption-text">check for equals/hashCode contract</p></div><br />
It was easy to run tests programmatically or from an Apache Ant task.</p>
<h2>History</h2>
<p>Tony Morris developed <a href="http://www.alphaworks.ibm.com/tech/junitx">Assertion Extensions for JUnit</a> (at that time known as JUnitX; not to be confused with other frameworks sharing the same name) a while ago. It contained advanced assertions to be used with plain old JUnit. When Java SE 5 was in beta, he started with the development of JTiger. Because of his contract as an employee of IBM, he needed permission by IBM to publish it as Open Source, even though he developed it in his free time. That process took several months. JTiger even crossed the desk of Erich Gamma, who commented on it in a private email to Tony Morris.</p>
<p>
While JTiger was in this approval process, TestNG has been released. At that time it had less fancy assertions (see examples above), but the concept was just as good and additional assertions have been introduced later. Also there were IDE-Plugins for Intellij Idea and Eclipse.</p>
<p>
After JTiger has been approved by IBM and released, it gained a fair amount of community acceptance. Independent comparisons with JUnit and TestNG were rather positive, such as <a href="http://www.theserverside.com/news/1365218/Test-Framework-Comparison">Justin Lee&#8217;s Test Framework Comparison</a>.</p>
<p>
In December 2005 I officially took charge of the project and Tony Morris retired from it. I never changed much except for the documentation and website, though.</p>
<p>
Early in 2010 the transfer of the domain ownership for jtiger.org to me failed. I don&#8217;t know what went wrong. I got the correct release code from Tony Morris and gave it to my registrar. A few days later my registrar informed me that either the current registrar or the owner (Tony Morris) did not approve the transfer. That was the end of the website.</p>
<h2>What now?</h2>
<p>In 2008, Tony Morris released Reductio. Similar to QuickCheck, it uses Automated Specification-based Testing. Reductio has become part of the <a href="http://functionaljava.org/">Functional Java</a> API.</p>
<p>
And of course you can still use JTiger:</p>
<p class="plaintext">
            <b><br />
                JTiger tar.gz<br />
            </b></p>
<p>            <a href="http://kaiwitte.org/jtiger/jtiger-2.1.0376.tar.gz">jtiger-2.1.0376.tar.gz</a>
        </p>
<p class="plaintext">
            <b></p>
<p>                JTiger MD5 tar.gz<br />
            </b></p>
<p>            <a href="http://kaiwitte.org/jtiger/jtiger-2.1.0376.tar.gz.MD5">jtiger-2.1.0376.tar.gz.MD5</a>
        </p>
<p class="plaintext">
            <b><br />
                JTiger zip<br />
            </b></p>
<p>
            <a href="http://kaiwitte.org/jtiger/jtiger-2.1.0376.zip">jtiger-2.1.0376.zip</a>
        </p>
<p class="plaintext">
            <b><br />
                JTiger MD5 zip<br />
            </b></p>
<p>            <a href="http://kaiwitte.org/jtiger/jtiger-2.1.0376.zip.MD5">jtiger-2.1.0376.zip.MD5</a>
        </p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/the-history-of-jtiger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slow Research &#8211; A Mod for Warzone 2100</title>
		<link>http://witte-consulting.com/blog/slow-research-a-mod-for-warzone-2100/</link>
		<comments>http://witte-consulting.com/blog/slow-research-a-mod-for-warzone-2100/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 21:32:42 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=212</guid>
		<description><![CDATA[This mod doubles the time for all research in Warzone 2100. Download Slow Research Mod Version 1.0 alpha 3 System requirements Warzone 2100 Version 2.3 beta 10 (MIGHT work with other versions). Installation See the reference on the official project website. Tactical motivation Experienced players have optimised their research in such a way that many [...]]]></description>
			<content:encoded><![CDATA[<p>This mod doubles the time for all research in <a href="http://wz2100.net/">Warzone 2100</a>.</p>
<p><a href="http://kaiwitte.org/slowresearch.wz">Download Slow Research Mod Version 1.0 alpha 3</a></p>
<h3>System requirements</h3>
<p>Warzone 2100 Version 2.3 beta 10 (MIGHT work with other versions).</p>
<h3>Installation</h3>
<p>See the <a href="http://wz2100.net/faq#HowdoIinstallamod">reference on the official project website</a>.</p>
<h3>Tactical motivation</h3>
<p>Experienced players have optimised their research in such a way that many technologies are outdated a few minutes after they have been researched. The lifespan of some weapons is very short in games with experienced players. For example ripple rockets are available in less than 19 minutes (T1, no starting bases), which makes mortars pretty much useless. When someone tries to use mortar or bombard pits, the opponent can simply build a few bunkers and wait for CB tower and ripple rockets. Even a huge field of mortar pits can only destroy a few bunkers before it gets smashed by ripple rockets.<br />
With this mod, ripple rockets will be available around game minute 37, which makes mortars more attractive.</p>
<p>It does <strong>not</strong> slow down the entire game! Production speed and unit movement speed as well as power income are unchanged. So <strong>relative</strong> to the research, these elements are twice as fast now. For example in the previously short time span from when twin mg gets researched until the research of heavy MG (or a different superior counter weapon like mini pod), a player can build twice as many tanks with twin MG and move twice as far with them as before.</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/slow-research-a-mod-for-warzone-2100/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java EE-Vortrag in Kiel</title>
		<link>http://witte-consulting.com/blog/java-ee-vortrag-in-kiel/</link>
		<comments>http://witte-consulting.com/blog/java-ee-vortrag-in-kiel/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 23:45:15 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=206</guid>
		<description><![CDATA[Hallo Teilnehmer, für die Codeschnipsel, die ich in der Präsentation gezeigt habe, habe ich ein kleines Java EE-Projekt angelegt, das Ihr hier herunterladen könnt: javaee-vortrag.zip Erwartet bitte nicht zu viel. Es macht nichts Sinnvolles, sondern enthält nur die gezeigten Programmteile. Allerdings funktioniert es, und Ihr könnt darauf zum Testen aufbauen. Ich helfe gern bei der [...]]]></description>
			<content:encoded><![CDATA[<p>Hallo Teilnehmer,</p>
<p>für die Codeschnipsel, die ich in der Präsentation gezeigt habe, habe ich ein kleines Java EE-Projekt angelegt, das Ihr hier herunterladen könnt:</p>
<p><a href="http://witte-consulting.com/javaee-vortrag.zip">javaee-vortrag.zip</a></p>
<p>Erwartet bitte nicht zu viel. Es macht nichts Sinnvolles, sondern enthält nur die gezeigten Programmteile. Allerdings funktioniert es, und Ihr könnt darauf zum Testen aufbauen. Ich helfe gern bei der Installation, falls die Anweisungen unter &#8220;Dokumentation&#8221; im zip nicht reichen sollten. Projektdateien für Intellij Idea und Eclipse (ungetestet) sind dabei.</p>
<p>Als komplettes Beispiel für eine Java EE 5 Applikation bietet sich ansonsten die <a href="https://blueprints.dev.java.net/petstore/">Pet Store Demo</a> von Sun an.</p>
<p>Wer den Stand der Technik mit Schwerpunkt Webfrontend durch Java EE-basierte Frameworks sehen will, für den bietet sich das Booking-Example von <a href="http://seamframework.org/">Seam</a> an oder auch die <a href="http://www.jboss.org/richfaces/demos.html">Demos von JBoss RichFaces</a>.</p>
<p>Fragen und Diskussion zum Vortrag oder zu Java EE gern hier in den Kommentaren, oder <a href="http://witte-consulting.com/contact/">kontaktiert mich direkt</a>.</p>
<p>Gruß</p>
<p>Kai</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/java-ee-vortrag-in-kiel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Too depraved to book a hotel</title>
		<link>http://witte-consulting.com/blog/too-depraved-to-book-a-hotel/</link>
		<comments>http://witte-consulting.com/blog/too-depraved-to-book-a-hotel/#comments</comments>
		<pubDate>Sat, 30 May 2009 20:10:10 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=190</guid>
		<description><![CDATA[For my business trip to Hamburg next week I booked an apartment. But today they cancelled. First reason is that they find a software developer who does not have a mobile phone suspicious. Second is the text on my private website which says: At first glance, this clean-cut, well mannered man appears to be an [...]]]></description>
			<content:encoded><![CDATA[<p>For my business trip to Hamburg next week I booked an apartment. But today they cancelled. First reason is that they find a software developer who does not have a mobile phone suspicious. Second is the text on my private website which says:</p>
<blockquote><p><img src="http://witte-consulting.com/blog/wp-content/uploads/2009/05/kai-jarvis.png" alt="Death Knight Kai" title="Death Knight Kai" width="82" height="82" class="alignleft size-full wp-image-198" /><br />
At first glance, this clean-cut, well mannered man appears to be an average <strong>software developer</strong>, but a dark heart dwells within that handsome exterior. <strong>Kai</strong> is one of the most depraved men alive. Nothing is sacred to him, and with each passing day he sinks further and further into his darkest thoughts.
</p>
</blockquote>
<p>It&#8217;s not astonishing at all that they do not understand it. It&#8217;s an insider joke for people who played <a href="http://en.wikipedia.org/wiki/Heroes_of_Might_and_Magic_IV">Heroes of Might and Magic IV</a> back in the days, which features a death knight with the same description (&quot;<a href="http://www.heroesofmightandmagic.com/heroes4/heroes_deathknights.shtml">Jarvis</a>&quot;):</p>
<blockquote><p><img src="http://witte-consulting.com/blog/wp-content/uploads/2009/05/jarvis.gif" alt="Death Knight Jarvis" title="Death Knight Jarvis" width="82" height="82" class="alignleft size-full wp-image-193" /><br />
At first glance, this clean-cut, well-mannered man appears to be an average <strong>knight</strong>, but a dark heart dwells within that handsome exterior. <strong>Jarvis</strong> is one of the most depraved men alive. Nothing is sacred to him, and with each passing day he sinks further and further into his darkest thoughts.
</p>
</blockquote>
<p>Strange is that someone would think that there really is a dark side to software development, and that those who have fallen to it would not only use PHP and Ruby on Rails, no, they would also devastate hotel rooms.</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/too-depraved-to-book-a-hotel/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Found undocumented trojan</title>
		<link>http://witte-consulting.com/blog/found-undocumented-trojan/</link>
		<comments>http://witte-consulting.com/blog/found-undocumented-trojan/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 13:10:31 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=162</guid>
		<description><![CDATA[I recently came across a trojan, which is detected by common virus scanners, but not much documented. So I analysed it just a little. Like many others it is located in the Windows directory (for example c:\winnt) and named svchost.exe (the real svchost.exe belongs to system32). It is set up to start with Windows. These [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a trojan, which is detected by common virus scanners, but not much documented. So I analysed it just a little.</p>
<p>Like many others it is located in the Windows directory (for example c:\winnt) and named <code>svchost.exe</code> (the real <code>svchost.exe</code> belongs to <code>system32</code>). It is set up to start with Windows.</p>
<p>These are its names according to <a href="http://virusscan.jotti.org/">jotti.org</a>:</p>

<div class="wp_syntax"><div class="code"><pre>A-Squared  	
Found Win32.SuspectCrc!IK
AntiVir 	
Found TR/Downloader.Gen
ArcaVir 	
Found Trojan.Agent.Wo
Avast 	
Found Win32:Trojan-gen {Other}
AVG Antivirus 	
Found BackDoor.Agent.MEA
BitDefender 	
Found Backdoor.Agent.WO
ClamAV 	
Found Trojan.Agent-8319
CPsecure 	
Found nothing
Dr.Web 	
Found BackDoor.IRC.Spreader
F-Prot Antivirus 	
Found W32/IRCBot-based!Maximus (probable variant)
F-Secure Anti-Virus 	
Found Backdoor.Win32.Agent.wo
G DATA 	
Found Win32:Trojan-gen
Ikarus 	
Found Win32.SuspectCrc
Kaspersky Anti-Virus 	
Found Backdoor.Win32.Agent.wo
NOD32 	
Found probably unknown NewHeur_PE (probable variant)
Norman Virus Control 	
Found W32/Agent.CWBV
Panda Antivirus 	
Found Trj/Downloader.MDW
Sophos Antivirus 	
Found Mal/Generic-A
VirusBuster 	
Found nothing
VBA32 	
Found Backdoor.Win32.Agent.wo</pre></div></div>

<p>The size is 86.016 bytes, MD5: 5ec89f1f189fc5af94aa9306d7df4b8b</p>
<p>What it does is this: It tries to connect to IRC.BENDOVER.BE (that server is no longer operational), then joins <code>#spreader.crew</code> (password: spreadmaster). In my case it used the name!id: <code>oppqrrstc!oppqrrstc</code> (probably generated individually). Then it stayed in the channel and did nothing more. It probably waited for a bot or real person to contact it with further instructions.</p>
<p>Any hints about this trojan or the creators (former owner of bendover.be? &quot;spreader.crew&quot;?) are appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/found-undocumented-trojan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to fix multiplayer_msg_general_failure</title>
		<link>http://witte-consulting.com/blog/how-to-fix-multiplayer_msg_general_failure/</link>
		<comments>http://witte-consulting.com/blog/how-to-fix-multiplayer_msg_general_failure/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 20:06:53 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=159</guid>
		<description><![CDATA[In Heroes of Might and Magic IV (aka Heroes of Might and Magic 4, HOMM 4, HOMM IV) this error occurs when the name of the executable used to launch the program differs: multiplayer_msg_general_failure The content of the executable does not matter, it is the name. So both must use for example h4tour351.exe, even though [...]]]></description>
			<content:encoded><![CDATA[<p>In Heroes of Might and Magic IV (aka Heroes of Might and Magic 4, HOMM 4, HOMM IV) this error occurs when the name of the executable used to launch the program differs:</p>

<div class="wp_syntax"><div class="code"><pre>multiplayer_msg_general_failure</pre></div></div>

<p>The content of the executable does not matter, it is the name. So both must use for example h4tour351.exe, even though in Equilibris 3.51 it has the same content as h4mod.exe.</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/how-to-fix-multiplayer_msg_general_failure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chess puzzle: The two pawns (medium)</title>
		<link>http://witte-consulting.com/blog/chess-puzzle-the-two-pawns-medium/</link>
		<comments>http://witte-consulting.com/blog/chess-puzzle-the-two-pawns-medium/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 05:39:07 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Chess]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=150</guid>
		<description><![CDATA[The moves following here look like a harmless, automated trade of the minor pieces. But actually I (white) missed a chance to win material here. What should I have done in move 14? The actual game is below. Find the moves for white that win material. [Event "rated standard match"] [Site "Free Internet Chess Server"] [...]]]></description>
			<content:encoded><![CDATA[<p>The moves following here look like a harmless, automated trade of the minor pieces. But actually I (white) missed a chance to win material here. What should I have done in move 14?</p>
<p>The actual game is below. Find the moves for white that win material.</p>
<pre>
<div class="CBB-board" style="display:none;">
[Event "rated standard match"]
[Site "Free Internet Chess Server"]
[Date "2008.10.18"]
[Round "?"]
[White "Magnakai"]
[Black "LinuxGuy"]
[Result "1/2-1/2"]
[WhiteElo "1634"]
[BlackElo "1852"]
[ECO "C00"]
[TimeControl "1800+30"]
[JsCom "startply 26"]

1. e4  e6  2. Nc3  d5
 3. exd5  exd5  4. d4
 Nf6  5. Bg5  Be7
6. Nf3  Bg4  7. Bb5+  c6
 8. Be2  O-O  9. O-O
 Nbd7  10. Re1  Re8
11. Ne5  Bxe2  12. Rxe2  Ne4
 13. Nxe4  Bxg5 $4
 ( 13.
... dxe4 14. Bf4 Nxe5 15. dxe5 g5 16. Bg3 Qxd1+ 17. Rxd1 Rad8 18. Rde1 h5 $11
 ) 14. Nxg5 $2
 ( 14. Nxf7 Qe7
(14. ... Kxf7 15. Nd6+ ) 15. Nfxg5 dxe4 16. Nxe4 Nf6 17. f3 Nxe4 18. fxe4 Rf8
19. Qd3 Qf7 $18  ) Nxe5  15. Rxe5
 Rxe5  16. dxe5 $2
 (
16. Nxf7 Re1+ (16. ... Kxf7 ) 17. Qxe1 Kxf7 18. Qe5 Qf6 19. Re1 Rf8 20. f3
Qxe5 21. dxe5 Ke6 22. Kf2 c5 $16  ) Qxg5
 17. Qd4  Re8  18. f4
 Qf5  19. Qxa7  Qxf4
 20. Qxb7  Qxe5  21. Qxc6
 Qe3+  22. Kf1  Qe2+
 23. Kg1   1/2-1/2
</div>
</pre>
<p>Hint 1: <a class="spoiler_link_show" href="javascript:void(0)" onclick="wpSpoilerToggle(document.getElementById('id1524173602'), this, 'show', 'hide')">show</a>
<span class="spoiler_div" id="id1524173602" style="display:none">Win the black d pawn and f pawn.</span>
</p>
<p>Hint 2: <a class="spoiler_link_show" href="javascript:void(0)" onclick="wpSpoilerToggle(document.getElementById('id939534232'), this, 'show', 'hide')">show</a>
<span class="spoiler_div" id="id939534232" style="display:none">The e5 knight takes both pawns.</span>
</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/chess-puzzle-the-two-pawns-medium/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JNI (Java Native Interface): Exception in thread &#8220;main&#8221; java.lang.UnsatisfiedLinkError: Can&#8217;t find dependent libraries</title>
		<link>http://witte-consulting.com/blog/jni-java-native-interface-exception-in-thread-main-javalangunsatisfiedlinkerror-can-t-find-dependent-libraries/</link>
		<comments>http://witte-consulting.com/blog/jni-java-native-interface-exception-in-thread-main-javalangunsatisfiedlinkerror-can-t-find-dependent-libraries/#comments</comments>
		<pubDate>Mon, 22 Sep 2008 06:48:51 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Computers]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=141</guid>
		<description><![CDATA[How to fix UnsatisfiedLinkError in JNI I have never had problems with JNI. In the few situations when I needed it, it just worked. But last week someone asked me for help with his problem. When I tried to reproduce it, I found out that it had spread even to my old JNI programs which [...]]]></description>
			<content:encoded><![CDATA[<h3>How to fix UnsatisfiedLinkError in JNI</h3>
<p>I have never had problems with JNI. In the few situations when I needed it, it just worked. But last week someone asked me for help with his problem. When I tried to reproduce it, I found out that it had spread even to my old JNI programs which worked until 2006!</p>
<p>When running a program that uses a native function the following error occured:</p>

<div class="wp_syntax"><div class="code"><pre>Exception in thread &quot;main&quot; java.lang.UnsatisfiedLinkError: Test.dll: Can't find dependent libraries</pre></div></div>

<p>It&#8217;s obviously a linker problem related to the generation of the .dll file. I have no idea why it occurs now and didn&#8217;t occur in the past. Different OS, compiler version, something like that? For some reason both the linker of Visual Studio and the linker of GCC started to think that is was a good idea to replace all method names by some arbitrary name which then cannot be found at runtime.</p>
<h4>Fix for GCC</h4>
<p>To fix that with GCC, the linker opion <code>--add-stdcall-alias</code> can be used.</p>

<div class="wp_syntax"><div class="code"><pre>gcc -Wl,--add-stdcall-alias -mno-cygwin -shared -I/cygdrive/c/Program\ Files/Java/jdk1.6.0_05/include -I/cygdrive/c/Program\ Files/Java/jdk1.6.0_05/include/win32 -o HelloWorld.dll HelloWorld.c</pre></div></div>

<h4>Fix for Visual C</h4>
<p>For Microsoft Visual C Compiler it should theoretically be possible with a linker option as well.</p>
<h5>Find out the correct linker option</h5>
<p>First compile and link in the usual way that didn&#8217;t work. This will create the .dll file which results in the error we are talking about. Then use the <code>dumpbin</code> tool to list the procedure names:</p>

<div class="wp_syntax"><div class="code"><pre>dumpbin HelloWorld.dll /EXPORTS</pre></div></div>

<p>You will find your procedure name, something like _Java_HelloWorld_print@8. Now try to guess what the name <strong>should</strong> be. My guess in this case would be Java_HelloWorld_print. This would result in the linker option <code>/EXPORT:Java_HelloWorld_print=_Java_HelloWorld_print@8</code></p>
<h5>Supply the linker option</h5>
<ol>
<li>Use a <code>#pragma comment</code> in the source file:

<div class="wp_syntax"><div class="code"><pre>#pragma comment(linker, &quot;/EXPORT:Java_HelloWorld_print=_Java_HelloWorld_print@8&quot;)</pre></div></div>

<p>OR</li>
<li>Split into linking and compiling and provide the option to the linker in the command line, OR</li>
<li>Supply it to the compiler at the end using <code>/link</code>:

<div class="wp_syntax"><div class="code"><pre>cl -I&quot;C:\Program Files\Java\jdk1.6.0_05\include&quot; -I&quot;c:\Program Files\java\jdk1.6.0_05\include\win32&quot; -MD -LD HelloWorld.c -FeHelloWorld.dll /link /EXPORT:Java_HelloWorld_print=_Java_HelloWorld_print@8</pre></div></div>

</li>
</ol>
<p><strong>Edit:</strong> According to user comments, the -MD option above is wrong and causes the problem described below. Do not use -MD! See <a href="http://msdn.microsoft.com/en-us/library/2kzt1wy3(VS.71).aspx">MSDN</a> for further information about the -MD option.</p>
<p>Option 3 is probably the easiest. After that <code>dumpbin</code> will show that now there is an additional procedure with the <strong>correct</strong> name:</p>

<div class="wp_syntax"><div class="code"><pre>dumpbin HelloWorld.dll /EXPORTS</pre></div></div>

<p>I even compared it with the <strong>working</strong> .dll I created with GCC (see above), and it looks the same! But it doesn&#8217;t work, still getting the same error!</p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/jni-java-native-interface-exception-in-thread-main-javalangunsatisfiedlinkerror-can-t-find-dependent-libraries/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Chess puzzle #24 (medium)</title>
		<link>http://witte-consulting.com/blog/chess-puzzle-24-medium/</link>
		<comments>http://witte-consulting.com/blog/chess-puzzle-24-medium/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 14:42:30 +0000</pubDate>
		<dc:creator>Kai Witte</dc:creator>
				<category><![CDATA[Chess]]></category>

		<guid isPermaLink="false">http://witte-consulting.com/blog/?p=117</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_118" class="wp-caption aligncenter" style="width: 310px"><a href="http://witte-consulting.com/blog/wp-content/uploads/2008/08/chess24.png"><img src="http://witte-consulting.com/blog/wp-content/uploads/2008/08/chess24.png" alt="White to move and win a pawn." title="Chess puzzle #24" width="300" height="243" class="size-medium wp-image-118" /></a><p class="wp-caption-text">White to move and win a pawn.</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://witte-consulting.com/blog/chess-puzzle-24-medium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

