<?xml version="1.0"?>
<rss version="2.0">
<channel>
	<title>Planet Classpath</title>
	<link>http://planet.classpath.org/</link>
	<language>en</language>
	<description>Planet Classpath - http://planet.classpath.org/</description>
	<ttl>30</ttl>

<item>
	<title>Mario Torre: A day in the life...</title>
	<guid>http://www.jroller.com/neugens/entry/a_day_in_the_life</guid>
	<link>http://www.jroller.com/neugens/entry/a_day_in_the_life</link>
	<description>&lt;p&gt;&lt;center&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/center&gt;&lt;/p&gt;</description>
	<pubDate>Sun, 21 Mar 2010 22:15:56 +0000</pubDate>
</item>
<item>
	<title>Mario Torre: This is a sad news...</title>
	<guid>http://www.jroller.com/neugens/entry/this_is_a_sad_news</guid>
	<link>http://www.jroller.com/neugens/entry/this_is_a_sad_news</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://www.cejug.org/2010/03/06/noticia-triste-para-o-java-no-brasil-e-o-ceara/&quot;&gt;http://www.cejug.org/2010/03/06/noticia-triste-para-o-java-no-brasil-e-o-ceara&lt;/a&gt;&lt;/p&gt;</description>
	<pubDate>Fri, 19 Mar 2010 18:38:49 +0000</pubDate>
</item>
<item>
	<title>Audrius Meskauskas: 19 Mar 2010</title>
	<guid>http://www.advogato.org/person/audriusa/diary.html?start=14</guid>
	<link>http://www.advogato.org/person/audriusa/diary.html?start=14</link>
	<description>Today I checked SourceForge after a long gap and discovered
that &lt;a href=&quot;http://www.advogato.org/person/audriusa/rss.xml&quot;&gt;StableUpdate&lt;/a&gt;
that I started years ago is alive, has two developers
without me and gets code contribution. It is really
impressive to see such things happening. Your code can live
without you! Not the first time I see it yet always impressive.</description>
	<pubDate>Fri, 19 Mar 2010 17:53:21 +0000</pubDate>
</item>
<item>
	<title>Andrew Overholt: Eclipse Linux Tools 0.5.0 Release</title>
	<guid>http://overholt.ca/wp/?p=154</guid>
	<link>http://overholt.ca/wp/?p=154</link>
	<description>&lt;p&gt;The Eclipse Linux Tools team is proud to announce our 0.5.0 release.  This&lt;br /&gt;
release is compatible with the Galileo releases of the Eclipse SDK (version&lt;br /&gt;
3.5.x) and CDT (version 6.0.x).  It is available now from our update site:&lt;/p&gt;
&lt;p&gt;&lt;center&gt;&lt;br /&gt;
http://download.eclipse.org/technology/linuxtools/update&lt;br /&gt;
&lt;/center&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://wiki.eclipse.org/Linux_Tools_Project/PluginInstallHelp&quot;&gt;Installation instructions&lt;/a&gt; are available.  &lt;a href=&quot;https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&amp;short_desc_type=allwordssubstr&amp;short_desc=&amp;classification=Technology&amp;product=Linux+Tools&amp;target_milestone=0.5&amp;long_desc_type=allwordssubstr&amp;long_desc=&amp;bug_file_loc_type=allwordssubstr&amp;bug_file_loc=&amp;status_whiteboard_type=allwordssubstr&amp;status_whiteboard=&amp;keywords_type=allwords&amp;keywords=&amp;bug_status=RESOLVED&amp;bug_status=VERIFIED&amp;bug_status=CLOSED&amp;emailtype1=substring&amp;email1=&amp;emailtype2=substring&amp;email2=&amp;bugidtype=include&amp;bug_id=&amp;votes=&amp;chfieldfrom=&amp;chfieldto=Now&amp;chfieldvalue=&amp;cmdtype=doit&amp;order=Reuse+same+sort+as+last+time&amp;field0-0-0=noop&amp;type0-0-0=noop&amp;value0-0-0&quot;&gt;70 bugs&lt;/a&gt; were closed as part of this release including bug fixes and new features. Highlights include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;tools for the analysis and visualization of LTTng traces&lt;br /&gt;
&lt;a href=&quot;http://www.eclipse.org/linuxtools/new-0.5/images-0.5/lttng_perspective_thumb.png&quot;&gt;&lt;img src=&quot;http://overholt.ca/wp/wp-content/uploads/2010/03/lttng_perspective_thumb.png&quot; alt=&quot;LTTng perspective&quot; title=&quot;LTTng perspective&quot; width=&quot;400&quot; height=&quot;250&quot; class=&quot;aligncenter size-full wp-image-159&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;GCov integration&lt;br /&gt;
&lt;a href=&quot;http://www.eclipse.org/linuxtools/new-0.5/images-0.5/gcov.png&quot;&gt;&lt;img src=&quot;http://overholt.ca/wp/wp-content/uploads/2010/03/gcov-sm.png&quot; alt=&quot;GCov screenshot&quot; title=&quot;GCov screenshot&quot; width=&quot;400&quot; height=&quot;277&quot; class=&quot;aligncenter size-full wp-image-166&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;a Dashboard perspective for visualising system activities&lt;br /&gt;
&lt;a href=&quot;http://www.eclipse.org/linuxtools/new-0.5/images-0.5/SystemTap_dashboard.png&quot;&gt;&lt;img src=&quot;http://overholt.ca/wp/wp-content/uploads/2010/03/SystemTap_dashboard.png&quot; alt=&quot;SystemTap dashboard&quot; title=&quot;SystemTap dashboard&quot; width=&quot;400&quot; height=&quot;276&quot; class=&quot;aligncenter size-full wp-image-158&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;many improvements to the scripts to build the Eclipse SDK for Linux distributions, now supporting Eclipse SDK version 3.5.2&lt;/li&gt;
&lt;li&gt;callgraphs of multi-threaded programs are now supported &lt;a href=&quot;http://www.eclipse.org/linuxtools/new-0.5/images-0.5/threaded-screenshot.png&quot;&gt;&lt;img src=&quot;http://overholt.ca/wp/wp-content/uploads/2010/03/threaded-screenshot.png&quot; alt=&quot;threaded callgraph&quot; title=&quot;threaded callgraph&quot; width=&quot;400&quot; height=&quot;360&quot; class=&quot;aligncenter size-full wp-image-156&quot; /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The full list of highlights can be see on our &lt;a href=&quot;http://eclipse.org/linuxtools/new&quot;&gt;new and noteworthy page&lt;/a&gt;.  That page also contains a list of community contributions to our 0.5 release from the following excellent individuals:  Niels Thykier, Benjamin Drung, and Jens Seidel.  Thanks to all for their hard work and contributions.  As usual, we very much appreciate feedback, be it &lt;a href=&quot;https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Linux%20Tools&quot;&gt;bugs&lt;/a&gt;, on IRC (Freenode #eclipse-linux), or on our &lt;a href=&quot;https://dev.eclipse.org/mailman/listinfo/linuxtools-dev&quot;&gt;mailing list&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Committers participating in this release include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;William Bourque&lt;/li&gt;
&lt;li&gt;Francois Chouinard&lt;/li&gt;
&lt;li&gt;Roland Grunberg&lt;/li&gt;
&lt;li&gt;Anithra P Janakiraman&lt;/li&gt;
&lt;li&gt;Jeff Johnston&lt;/li&gt;
&lt;li&gt;Alexander Kurtakov&lt;/li&gt;
&lt;li&gt;Andrew Overholt&lt;/li&gt;
&lt;li&gt;Xavier Raynaud&lt;/li&gt;
&lt;li&gt;Alvaro Sanchez-Leon&lt;/li&gt;
&lt;li&gt;Charley Wang&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Thanks to everyone and looking forward to 0.6 which will be a part of the Helios release train.&lt;/p&gt;</description>
	<pubDate>Thu, 18 Mar 2010 20:35:49 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: Beware of Covariant Overriding in Interface Hierarchies</title>
	<guid>http://blogs.sun.com/darcy/entry/covariant_interface_hierarchies</guid>
	<link>http://blogs.sun.com/darcy/entry/covariant_interface_hierarchies</link>
	<description>&lt;p&gt;

One of the changes to the Java programming language made back in JDK 5 was the introduction of 
&lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Covariant_return_type&quot;&gt;covariant returns&lt;/a&gt;&lt;/i&gt;, that is, the ability in a subtype to override a method in a supertype and return a more specific type.  For example,

&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
public class A {
  public Object method() {return null;}
}

public class B extends A {
  @Override
  public String method() {return &quot;&quot;;}
}
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;

Covariant returns can be a very handy facility to more accurately convey the type of object returned by a method.  However, the feature should be used judiciously, especially in interface hierarchies.  In interface hierarchies, covariant returns force constraints on the implementation classes.  Such a constraint was included the in the &lt;code&gt;apt&lt;/code&gt; API modeling the Java language and was subsequently removed from the analogous portion of the standardized JSR 269 API in &lt;code&gt;javax.lang.model.*&lt;/code&gt;.

&lt;/p&gt;

&lt;p&gt;

In &lt;code&gt;apt&lt;/code&gt;, the 
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/jdk/api/apt/mirror/com/sun/mirror/declaration/TypeDeclaration.html&quot;&gt;TypeDeclaration&lt;/a&gt;&lt;/code&gt; interface defines a method&lt;br /&gt; 
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/jdk/api/apt/mirror/com/sun/mirror/declaration/TypeDeclaration.html#getMethods()&quot;&gt;Collection&amp;lt;? extends MethodDeclaration&amp;gt; getMethods()&lt;/a&gt;&lt;/code&gt;.&lt;br /&gt;

In the sub-interface 
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/jdk/api/apt/mirror/com/sun/mirror/declaration/ClassDeclaration.html&quot;&gt;ClassDeclaration&lt;/a&gt;&lt;/code&gt;, the method is overriden with&lt;br /&gt; 
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/jdk/api/apt/mirror/com/sun/mirror/declaration/ClassDeclaration.html#getMethods()&quot;&gt;Collection&amp;lt;MethodDeclaration&amp;gt; getMethods()&lt;/a&gt;&lt;/code&gt;&lt;br /&gt; and in another sub-interface, 
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/jdk/api/apt/mirror/com/sun/mirror/declaration/AnnotationTypeDeclaration.html&quot;&gt;AnnotationTypeDeclaration&lt;/a&gt;&lt;/code&gt;, the method is overriden with&lt;br /&gt;
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/jdk/api/apt/mirror/com/sun/mirror/declaration/AnnotationTypeDeclaration.html#getMethods()&quot;&gt;Collection&amp;lt;AnnotationTypeElementDeclaration&amp;gt; getMethods()&lt;/a&gt;&lt;/code&gt;.&lt;br /&gt;

Consequently, it is not possible for a single class to implement both the &lt;code&gt;ClassDeclaration&lt;/code&gt; and &lt;code&gt;AnnotationTypeDeclaration&lt;/code&gt; interfaces since the language specification forbids having two methods with the same name and argument types but different return types 
(&lt;a href=&quot;http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.2&quot; title=&quot;Method Signature&quot;&gt;JLSv3 &amp;sect;8.4.2&lt;/a&gt;).

(This restriction does not exist at the class file level and a compiler will generate synthetic &lt;i&gt;bridge methods&lt;/i&gt; with this property when implementing covariant returns.)


If a compiler chose to use a single type to model all kinds of types (classes, enums, interfaces, annotation types), it would &lt;em&gt;not&lt;/em&gt; be able to be directly retrofitted to implement the entirely of this &lt;code&gt;apt&lt;/code&gt; API; wrapper objects would need to be created just to allow the interfaces to be implemented at a source level.

&lt;/p&gt;

&lt;p&gt;

In contrast, in JSR 269 the root modeling interface 
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/element/Element.html&quot;&gt;Element&lt;/a&gt;&lt;/code&gt; defines a 
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/element/Element.html#getEnclosedElements()&quot;&gt;List&amp;lt;? extends Element&amp;gt; getEnclosedElements()&lt;/a&gt; method which returns all kinds of enclosed elements, from fields, to constructors, to methods.  Elements of a particular type can than be extracted using a &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/util/ElementFilter.html&quot;&gt;filter&lt;/a&gt;.  This approach provides more flexibility in retrofitting the interfaces onto an existing implementation; a spectrum of implementations are possible, from a single type to represent all sorts of elements to a one-to-one correspondence of implementation types to interface types.

&lt;/p&gt;

&lt;p&gt;

Note that in cases where an implementation type collapses several interface types, &lt;code&gt;instanceof&lt;/code&gt; checks for an interface type are not necessarily useful since implementing one interface does &lt;em&gt;not&lt;/em&gt; imply no other related interface is implemented.  The 
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/element/Element.html&quot;&gt;&lt;code&gt;Element&lt;/code&gt;&lt;/a&gt; specification warns of this possibility:

&lt;/p&gt;

&lt;blockquote&gt;
To implement operations based on the class of an &lt;code&gt;Element&lt;/code&gt; object, either use a visitor or use the result of the &lt;code&gt;getKind()&lt;/code&gt;  method. Using &lt;code&gt;instanceof&lt;/code&gt; is not necessarily a reliable idiom for determining the effective class of an object in this modeling hierarchy since an implementation may choose to have a single object implement multiple &lt;code&gt;Element&lt;/code&gt; subinterfaces. 
&lt;/blockquote&gt;</description>
	<pubDate>Mon, 15 Mar 2010 17:00:00 +0000</pubDate>
</item>
<item>
	<title>Mario Torre: Fortune of the day</title>
	<guid>http://www.jroller.com/neugens/entry/fortune_of_the_day6</guid>
	<link>http://www.jroller.com/neugens/entry/fortune_of_the_day6</link>
	<description>&lt;pre&gt;Your true value depends entirely on what you are compared with.&lt;/pre&gt;</description>
	<pubDate>Mon, 15 Mar 2010 12:08:46 +0000</pubDate>
</item>
<item>
	<title>Mario Torre: Profiling code</title>
	<guid>http://www.jroller.com/neugens/entry/profiling_code</guid>
	<link>http://www.jroller.com/neugens/entry/profiling_code</link>
	<description>&lt;p&gt;This weekend I had a chance to play a bit with the &lt;a href=&quot;http://en.wikipedia.org/wiki/SIMD&quot;&gt;SIMD&lt;/a&gt; instructions of a variety of architectures (in particular the Playstation3 Cell BE and my laptop Intel Centrino vPro machine). I think I'll share the results of those tests in a different article, but for now I just want to talk about the different solutions (and especially their drawbacks) that can be used to measure the time passed while executing a critical section of code.&lt;/p&gt;


&lt;p&gt;While micro optimisations and micro benchmarking are usually evil for a number of reason, from time to time it's interesting to measure the performance of a chunk of code, even when the chunk is indeed small, either for comparison or to collect statistics of performance critical sections. Other times instead it's mandatory to have such measurement in order to ensure that a critical section of code runs at a constant (or at least stable) speed. One example of this that comes to my mind right now may be the main game loop of a video game.&lt;/p&gt;


&lt;p&gt;All of the following methods measure the time elapsed since a known &quot;checkpoint&quot; in time, so they all require you to grab the measure two times, one at the beginning and one at the very end of the measured section of code, and subtract the two values. The difference lies in the way this operation is performed (for example some methods use some specific structures and you need to subtracts the values of their fields), on the resolution and on the accuracy of the measurement. Not all methods are reliable in all cases for example, or the resolution may be too small to give correct results for a given problem.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Using time&lt;/strong&gt;&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
int time(time_t *calptr);&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;


&lt;p&gt;The funtion &lt;a href=&quot;http://linux.die.net/man/2/time&quot;&gt;&lt;code&gt;time&lt;/code&gt;&lt;/a&gt; it's declared in &lt;code&gt;time.h&lt;/code&gt;. This function has only one second resolution, measuring time in seconds elapsed since &lt;a href=&quot;http://en.wikipedia.org/wiki/Unix_epoch&quot;&gt;the Epoch&lt;/a&gt; (oh, I wanted to write this since ever!), there are not many real use cases I think, but probably is the most portable method across the various Operating Systems.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Using gettimeofday&lt;/strong&gt;&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;


&lt;p&gt;The &lt;a href=&quot;http://linux.die.net/man/2/gettimeofday&quot;&gt;&lt;code&gt;gettimeofday&lt;/code&gt;&lt;/a&gt; function is a BSD derived function declared in &lt;code&gt;sys/time.h&lt;/code&gt;. As it sounds, you may guess that it's portable across the various Operating Systems, because it's POSIX and basically it's there in all BSD/HP/Linux/QNX/Whatever system you have, but the problem is that it's resolution is variable. In fact &lt;code&gt;timeval&lt;/code&gt; contains a field that supports microsecond resolution (one millionth of a second) but whose granularity maybe not of 1 ms (and in fact it's not most of the time).&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Reading directly the high resolution time register&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;This is the least portable way, as it relies on a specific instruction to access the high resolution time register of the target CPU. Not only, the concept of &quot;high resolution time register&quot; is fluff. ARM, as far as I know, doesn't have it. Recent PowerPC have a cool register called &quot;Time Base&quot; register and an associated assembly instruction, &lt;code&gt;mftb&lt;/code&gt;. This is the case for example in the Playstation 3 Cell BE (which is probably my favourite architecture) Power Processing Unit, but if you want to profile the SPU you don't have access to this register directly. For the SPU elements you can use the SPU Decrementer and its associated instrinsics instead. This method is non portable also for older PowerPC, because they do not have the &lt;code&gt;mftb&lt;/code&gt; instruction at all (and those older architecture version are very common in the embedded world). In this case you need to access two special purpose registers, &lt;code&gt;TBL&lt;/code&gt; and &lt;code&gt;TBU&lt;/code&gt; using the &lt;code&gt;mfspr&lt;/code&gt; instruction.&lt;/p&gt;


&lt;p&gt;The Intel version of such register is called &quot;Time Stamp Counter&quot; and it's assembly is &lt;code&gt;rdtsc&lt;/code&gt;. This one is available from the Pentium processor family and on, but you still have to take care to detect it on Intel compatible systems. Also on some CPU it suffers from problems when power saving is activated, it may give incorrect results when out of order execution is performed, or in general when threads are being run on multicore/multiprocessor systems.&lt;/p&gt;


&lt;p&gt;I'm afraid of pasting m$ related stuff, and even linking it from my blog is some sort of a sin, but &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ee417693(VS.85).aspx&quot;&gt;this page&lt;/a&gt; has some details about the issues, so it's a good read after all.&lt;/p&gt;


&lt;p&gt;One way to fix the out of order execution problem is to call the &lt;code&gt;cpuid&lt;/code&gt; instruction, because it forces every pending instruction to be executed before it is called, with the effect of actually disabling out of order execution.&lt;/p&gt;


&lt;p&gt;This instrinc could be used to read the Time Stamp Counter:&lt;/p&gt;


&lt;p&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;
static inline unsigned long long rdtsc(void)&lt;br /&gt;
{&lt;br /&gt;
    unsigned hi, lo;&lt;br /&gt;
    __asm__ __volatile__ (&lt;br /&gt;
        &quot;xorl %%eax, %%eax\n&quot;&lt;br /&gt;
        &quot;cpuid\n&quot;&lt;br /&gt;
        &quot;rdtsc\n&quot;&lt;br /&gt;
        : &quot;=a&quot; (lo), &quot;=d&quot; (hi)&lt;br /&gt;
        : /* no input operands */&lt;br /&gt;
        : &quot;%ebx&quot;, &quot;%ecx&quot;);&lt;br /&gt;
    return (unsigned long long) hi  32 | lo;&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;


&lt;p&gt;The &lt;code&gt;unsigned long long&lt;/code&gt; value returned by reading the time register is usually measured in ticks elapsed since last time the CPU got resetted, so to get microsends out of ticks you need to know the frequency the clock is spinning (for example by reading &lt;code&gt;/proc/cpuinfo&lt;/code&gt;).&lt;/p&gt;


&lt;p&gt;See what I mean for non portable?&lt;/p&gt;


&lt;p&gt;So, this is a good idea on some platform and a bad idea on others, although generally works fine if you do it correctly, but in my opinion it's quite a pain unless you do very specific things.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Using clock_gettime&lt;/strong&gt;&lt;br /&gt;
&lt;pre&gt;&lt;br /&gt;
int clock_gettime(clockid_t clk_id, struct timespec *tp);&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;


&lt;p&gt;Last but not least the method that I think is the most accurate while maintaining a good deal of portability. &lt;code&gt;clock_gettime&lt;/code&gt; is again a Posix function, but it depends on a separate library, &lt;code&gt;rt&lt;/code&gt;, in order to be linked (let's say like this, it's not linked as part of the standard libc linkage like &lt;code&gt;gettimeofday&lt;/code&gt; is for example). Also, gcc doesn't like it if you specify the &lt;code&gt;-c99&lt;/code&gt; option, so you need to define &lt;code&gt;_POSIX_C_SOURCE=199309L&lt;/code&gt; as well.&lt;/p&gt;


&lt;p&gt;Once this is done, the function is declared in &lt;code&gt;time.h&lt;/code&gt;. The resolution is nanoseconds although the exact precision can be queried by using another function, &lt;code&gt;clock_getres&lt;/code&gt;. They all take as first argument the clock id; it is in fact possible to specify a different type of clock to query, although again the number of clocks supported are system dependants.&lt;/p&gt;


&lt;p&gt;Most of the time we are probably interested in querying either the CPU time or the Thread time, using &lt;code&gt;CLOCK_PROCESS_CPUTIME_ID&lt;/code&gt; or &lt;code&gt;CLOCK_THREAD_CPUTIME_ID&lt;/code&gt;, as far as I know this function is free from most of the problems that affect the other methods.&lt;/p&gt;


&lt;p&gt;The &lt;code&gt;timespec&lt;/code&gt; struct is similar to the &lt;code&gt;timeval&lt;/code&gt; one defined for &lt;code&gt;gettimeofday&lt;/code&gt;:&lt;/p&gt;


&lt;p&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;
struct timespec {&lt;br /&gt;
    time_t   tv_sec;        /* seconds */&lt;br /&gt;
    long     tv_nsec;       /* nanoseconds */&lt;br /&gt;
};&lt;/code&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;


&lt;p&gt;One common operation, as said before, is to subtract between two &lt;code&gt;timespec&lt;/code&gt; values before printing the result, this function may be used (I derived this from the gcc manual):&lt;/p&gt;


&lt;p&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;
static inline void timespecSubtract(struct timespec *result,&lt;br /&gt;
                                    struct timespec *start,&lt;br /&gt;
                                    struct timespec *stop)&lt;br /&gt;
{&lt;br /&gt;
    if (stop-&gt;tv_nsec  start-&gt;tv_nsec) {&lt;br /&gt;
        result-&gt;tv_sec = stop-&gt;tv_sec - start-&gt;tv_sec - 1;&lt;br /&gt;
        result-&gt;tv_nsec = 1000000000 + stop-&gt;tv_nsec - start-&gt;tv_nsec;&lt;br /&gt;
    } else {&lt;br /&gt;
        result-&gt;tv_nsec = stop-&gt;tv_nsec - start-&gt;tv_nsec;&lt;br /&gt;
        result-&gt;tv_sec = stop-&gt;tv_sec - start-&gt;tv_sec;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;/pre&gt;&lt;/p&gt;


&lt;p&gt;As with &lt;code&gt;gettimeofday&lt;/code&gt;, we store the elapsed time in second in the &lt;code&gt;tv_sec&lt;/code&gt; member, and the additional nanoseconds in the &lt;code&gt;tv_nsec&lt;/code&gt; member.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;Even a simple task as measuring elapsed time is more tricky than one could ever expect, but despite the million different ways of doing this, each with its own drawback, benefit and corner cases, it's definitely possible to still write portable code by abstracting this functionality. I hope I gave a good overview of some of the most interesting options. Also, the Internet has as always a great deal of documentation about this topic in case you want to know more on the subject.&lt;/p&gt;


&lt;p&gt;For example I found a good discussion about &lt;code&gt;clock_gettime&lt;/code&gt; &lt;a href=&quot;http://www.guyrutenberg.com/2007/09/22/profiling-code-using-clock_gettime/&quot;&gt;here&lt;/a&gt;, where the author gives a similar function in order to subtract &lt;code&gt;timespec&lt;/code&gt; values. &lt;a href=&quot;http://en.wikipedia.org/wiki/Time_Stamp_Counter&quot;&gt;Wikipedia&lt;/a&gt; has an interesting entry abut the Time Stamp Counter. The &lt;a href=&quot;http://www.ibm.com/developerworks/&quot;&gt;IBM Developer Works&lt;/a&gt; website is as always a very great source of information, and has a good article about the &lt;a href=&quot;http://www.ibm.com/developerworks/library/pa-timebase/&quot;&gt;Time Base Register&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;As always, &lt;code&gt;man&lt;/code&gt; is your friend. The Linux man page entries for the functions presented are a great starting point (and most of the time all you need) to understand the functions under discussion. The &lt;a href=&quot;http://docs.hp.com/en/&quot;&gt;HP&lt;/a&gt; and &lt;a href=&quot;http://developer.apple.com/Mac/library/documentation/&quot;&gt;Apple&lt;/a&gt; developers sites are also very good, as they sometimes highlight specific issues that can help coding with portability in mind. Finally, &lt;a href=&quot;http://stackoverflow.com/&quot;&gt;Stackoverflow&lt;/a&gt; is another website that is particularly helpful to find answer to common (and at times not so common) programming related questions.&lt;/p&gt;</description>
	<pubDate>Fri, 12 Mar 2010 20:14:27 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: Last Round Compiling</title>
	<guid>http://blogs.sun.com/darcy/entry/last_round_compiling</guid>
	<link>http://blogs.sun.com/darcy/entry/last_round_compiling</link>
	<description>&lt;p&gt;

As of build 85 of JDK 7, bug &lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6634138&quot;&gt;6634138 &quot;Source generated in last round not compiled&quot;&lt;/a&gt; has been fixed in &lt;code&gt;javac&lt;/code&gt;.

Previously, source code generated in a &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/annotation/processing/RoundEnvironment.html&quot;&gt;round of annotation processing&lt;/a&gt; where &lt;code&gt;RoundEnvironment.processingOver()&lt;/code&gt; was true was not compiled.

With the fix, source generated in the last round is compiled, but, as intended, while compiled such source still does not undergo annotation processing since processing is over.

The fix has also been applied to OpenJDK 6 build 19.

&lt;/p&gt;</description>
	<pubDate>Fri, 12 Mar 2010 19:53:19 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: Annotation Processor SourceVersion</title>
	<guid>http://blogs.sun.com/darcy/entry/annotation_processor_sourceversion</guid>
	<link>http://blogs.sun.com/darcy/entry/annotation_processor_sourceversion</link>
	<description>&lt;p&gt;

In annotation processing there are three distinct roles, 
&lt;a href=&quot;http://blogs.sun.com/darcy/resource/J1_2005-TS-7425.pdf&quot; title=&quot;JavaOne 2005: Annotation Processing for the Java™ Programming Language&quot;&gt;the author of the annotation types, the author of the annotation processor, and the client of the annotations&lt;/a&gt;.  The third role includes the responsibility to configure the compiler correctly, such as 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/build_advice_set_source_target&quot; title=&quot;Build Advice: Set Source, Target, and Encoding&quot;&gt;setting the source, target, and encoding options&lt;/a&gt; and 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/annotation_processing_build_advice_set&quot; title=&quot;Annotation Processing Build Advice: Set source and class file destinations&quot;&gt;setting the source and class file destination for annotation processing&lt;/a&gt;.

The author of the annotation processor shares a related responsibility: property returning &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Processor.html#getSupportedSourceVersion()&quot;&gt;the source version supported by the processor&lt;/a&gt;.

&lt;/p&gt;

&lt;p&gt;

Most processors can be written against a particular source version and always return that source version, such as by including a &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/annotation/processing/SupportedSourceVersion.html&quot;&gt;&lt;code&gt;@SupportedSourceVersion&lt;/code&gt;&lt;/a&gt; annotation on the processor class. 

In principle, the annotation processing infrastructure could tailor the view of newer-than-supported language constructs to be more compatible with existing processors.  Conversely, processors have the flexibility to implement
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/jdk_6_build_101_jsr&quot; title=&quot;http://blogs.sun.com/darcy/entry/jdk_6_build_101_jsr&quot;&gt;their own policies&lt;/a&gt; when encountering objects representing newer-than-supported structures.

In brief, by extending version-specific abstract visitor classes, such as 
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/util/AbstractElementVisitor6.html&quot;&gt;AbstractElementVisitor6&lt;/a&gt; and
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/util/AbstractTypeVisitor6.html&quot;&gt;AbstractTypeVisitor6&lt;/a&gt;, the &lt;code&gt;visitUnknown&lt;/code&gt; method will be called on entities newer than the version in question. 

&lt;/p&gt;

&lt;p&gt;

Just as regression tests inside the JDK itself should by default follow a dual policy of accepting the default source and target settings rather than setting them explicitly like other programs, annotation processors used for testing with the JDK should generally support the latest source version and not be constrained to a particular version.  This allows any issues or unexpected interactions of new features to be found more quickly and keeps the regression tests exercising the most recent code paths in the compiler.

&lt;/p&gt;

&lt;p&gt;

This dual policy is now consistently implemented in the &lt;code&gt;langtools&lt;/code&gt; regression tests as of build 85 of JDK 7 (&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6926699&quot; title=&quot;Annotation processing regression tests should typically return SourceVersion.latest&quot;&gt;6926699&lt;/a&gt;).
&lt;/p&gt;</description>
	<pubDate>Fri, 12 Mar 2010 18:00:00 +0000</pubDate>
</item>
<item>
	<title>Gary Benson: Shark</title>
	<guid>http://gbenson.net/?p=176</guid>
	<link>http://gbenson.net/?p=176</link>
	<description>&lt;p&gt;I&amp;#8217;m back on Shark, after a four month hiatus.  A minor milestone: it can &lt;a href=&quot;http://icedtea.classpath.org/hg/icedtea6/rev/39180582f106&quot;&gt;build itself&lt;/a&gt; again.&lt;/p&gt;</description>
	<pubDate>Fri, 12 Mar 2010 09:30:12 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: An Assertive Quality in Langtools</title>
	<guid>http://blogs.sun.com/darcy/entry/assertive_quality_langtools</guid>
	<link>http://blogs.sun.com/darcy/entry/assertive_quality_langtools</link>
	<description>&lt;p&gt;

With a duo of fixes in JDK 7 build 85, one by &lt;a href=&quot;http://blogs.sun.com/jjg/&quot;&gt;Jon&lt;/a&gt; 
(&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6927797&quot; title=&quot;langtools/test/tools/javac/EarlyAssert.java fails when run with assertions enabled (-ea)&quot;&gt;6927797&lt;/a&gt;) 
and another by me (&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6926703&quot; title=&quot;apt tests should run with assertions enabled&quot;&gt;6926703&lt;/a&gt;), the &lt;code&gt;langtools&lt;/code&gt; repository has reached another milestone in testing robustness: all the tests pass with assertions (&lt;code&gt;-ea&lt;/code&gt;) and system assertions (&lt;code&gt;-esa&lt;/code&gt;) enabled.  This adds to other useful &lt;code&gt;langtools&lt;/code&gt; testing properties, such as being able to successufully run in the speedy 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/openjdk6_build_13_regression_tests&quot;&gt;same vm testing mode&lt;/a&gt;.

&lt;/p&gt;

&lt;p&gt;

Jon's fix was just updating a test so that some code would always be run with assertions &lt;em&gt;disabled&lt;/em&gt; while my fix corrected an actual buggy assert I included in &lt;code&gt;apt&lt;/code&gt;.  Addressing such problems helps simplify analyzing test results; if there is a failure, there is a problem!

&lt;/p&gt;

&lt;p&gt;

These fixes have also been applied in the forthcoming OpenJDK 6 build 19 so it too will have the same assertive testing quality.

&lt;/p&gt;</description>
	<pubDate>Fri, 12 Mar 2010 00:40:21 +0000</pubDate>
</item>
<item>
	<title>Mario Torre: OS9... :S</title>
	<guid>http://www.jroller.com/neugens/entry/os9_s</guid>
	<link>http://www.jroller.com/neugens/entry/os9_s</link>
	<description>&lt;p&gt;Or &amp;#8220;things you would do to not use Windows&amp;#8221;...&lt;/p&gt;

	&lt;p&gt;Here is the recipe:&lt;/p&gt;

	&lt;p&gt;1. A decent Operating System with a sane Desktop Environment (in other words Fedora 12 + Gnome because it has gvfs, which is the coolest thing in the World)&lt;br /&gt;
2. &lt;span class=&quot;caps&quot;&gt;VPN&lt;/span&gt;/SSH access to a Linux host that has a share to all the Windows based toolchain.&lt;br /&gt;
3. Some scripts to automate compilation for the test files (in my case, all the usual make machinery for Jamaica).&lt;br /&gt;
4. A Windows shell that is used only to invoke the build machinery (and only that!).&lt;br /&gt;
5. Samba/NFS to share the sane Linux directories with the borked Windows machine.&lt;br /&gt;
6. &lt;span class=&quot;caps&quot;&gt;FTP&lt;/span&gt; whatever to upload the &lt;span class=&quot;caps&quot;&gt;OS9&lt;/span&gt; binaries to the target device.&lt;br /&gt;
7. &lt;span class=&quot;caps&quot;&gt;MAUI&lt;/span&gt; and &lt;span class=&quot;caps&quot;&gt;OS9&lt;/span&gt; documentation.&lt;/p&gt;

	&lt;p&gt;Preparation (for 1 person):&lt;/p&gt;

	&lt;p&gt;Just open a connection with nautilus to the remote Linux machine. On a separate terminal ssh into the same Linux machine and link the toolchain header files directory on a directory that is local to the mounted home (ugh, that&amp;#8216;s a complex sentence). This is needed only if the toolchain location is not on the local machine (like in my case is mounted via nfs), the reason is that the gvfs share will only see the remote Linux machine but not all that is mounted remotely there, so the trick of linking is necessary. Create the project in NetBeans telling it that the location of the header files is the shared folder that was made visible via gvfs. Edit code as necessary. Now the tricky part. When you compile huge amount of code gvsf crashes because NetBeans polls every file that is modified and make modifies them (it set the timestamps!) so never, ever ever, never use the same virtual desktop to edit code and to issue the make command. Just go back coding when make finishes (it&amp;#8216;s windows, so is supposed to be slow). Remember this again, don&amp;#8216;t focus NetBeans when windows compiles code. I think this is a weird bug in gvfs, and hopefully it will be fixed. If gvfs crashes, you need to restart and reaload the project in NetBeans, which takes more time that waiting for the compilation to finish&amp;#8230; Ah, make the customers that provide a windows only toolchain to pay twice is a good thing to do also.&lt;/p&gt;

	&lt;p&gt;End result: Jamaica runs on &lt;span class=&quot;caps&quot;&gt;OS9&lt;/span&gt; with &lt;span class=&quot;caps&quot;&gt;MAUI &lt;/span&gt;:)&lt;/p&gt;</description>
	<pubDate>Thu, 11 Mar 2010 22:43:14 +0000</pubDate>
</item>
<item>
	<title>Xerxes Rånby: How to get Shark LLVM JIT CodeGen crash bugs fixed!</title>
	<guid>http://labb.zafena.se/?p=362</guid>
	<link>http://labb.zafena.se/?p=362</link>
	<description>&lt;p&gt;When making a programming tool or a virtual machine getting the tool running perfectly stable without any crash bugs are always on a higher priority than gaining more speed. A crashing tool are a broken tool so I will share some tricks that I have practised to find and fix Shark LLVM JIT CodeGen crash bugs. The main trick are to be able generate reproducable testcases that can be reported to the LLVM developers bugzilla bugtracker by using what you can extract from the Shark LLVM JIT CodeGen crashes. Here is how I do it, enjoy!&lt;/p&gt;
&lt;p&gt;&lt;b&gt; How to provoke hard to find Shark LLVM JIT bugs &lt;/b&gt;&lt;br /&gt;
Some Shark LLVM JIT bugs are hard to find because they only occour after the Shark JIT enabled JVM have been running for a long time, this are because the Shark Hotspot JVM takes advantage of the fact that a given running application spends about 90% of its time running only 10% of the applications code. Hotspot profiles the running code and only JITs the most frequently used methods of the program. Hotspot uses a threshold to determine which methods to JIT. When a method have been used more than 100000 times then it are scheduled to be optimized by the JIT. JIT bugs can stay undetected if they are located in unfrequently executed methods, those methods that makes up the 90%, of the unfrequently executed application code.&lt;/p&gt;
&lt;p&gt;A easy trick to provoke unfrequently executed JIT bugs are to lower the JIT threshold in Hotspot so that Hotspot JITs everything. The JIT threshold can be controlled by using the -XX:CompileThreshold=1 option and -Xbatch option. -Xbatch prevents the hotspot from running the JIT in background and will make hotspot reproduce JIT bugs more determistic. &lt;/p&gt;
&lt;p&gt;Using a low JIT threshold will of course make the program startup magnitudes slower but it will also eventually find and hit all JIT bugs for a given application. Try pass -XX:+PrintCompilation to Hotspot as well so that you can observe all the java methods that Hotspot are JITting and find out which method that failed to JIT if Hotspot hits a JIT crash bug.&lt;br /&gt;
&lt;code&gt;java -XX:CompileThreshold=1 -Xbatch -XX:+PrintCompilation JavaApplication&lt;br /&gt;
 1  b   java.lang.Thread:: (49 bytes)&lt;br /&gt;
&amp;#8230;&lt;br /&gt;
 10  b   java.lang.String::getChars (66 bytes)&lt;br /&gt;
*crash*&lt;br /&gt;
/home/xerxes/llvm/include/llvm/CodeGen/MachineFrameInfo.h:289: int64_t&lt;br /&gt;
llvm::MachineFrameInfo::getObjectOffset(int) const: Assertion&lt;br /&gt;
`!isDeadObjectIndex(ObjectIdx) &amp;#038;&amp;#038; &amp;#8220;Getting frame offset for a dead object?&amp;#8221;&amp;#8216;&lt;br /&gt;
failed.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Huh.. no logfile??&lt;br /&gt;
Most Shark LLVM JIT CodeGen crash bugs makes the JVM instantainiously exit without producting a hs_err_pid*.log file. Whats usefull are that the JVM output will contain a Assertion, Unreachable or Unimplemented keyword and a LLVM code line numer.&lt;/p&gt;
&lt;p&gt;So what do we do now?&lt;br /&gt;
Thanks by using -XX:+PrintCompilation makes us aware that the last method JITed was the java.lang.String::getChars method and that caused the Assertion in the LLVM CodeGen when running the Shark JIT so the next step are to dump the LLVM IR that Shark have generated for the method.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt; Extract the LLVM IR for the java method that makes the Shark JIT crash.&lt;/b&gt;&lt;br /&gt;
Ok so we got a crash and we know that it was JITing of java.lang.String::getChars that caused it.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;a)&lt;/b&gt; shark debug build -XX:SharkPrintBitcodeOf= method:&lt;br /&gt;
If you have built a &lt;a href=&quot;http://gbenson.net/?p=100&quot;&gt;debuggable &amp;#8220;Mixtech&amp;#8221; Shark build&lt;/a&gt; then Shark will contain some extra usefull debug runtimeoptions where one of the more usefull are&lt;br /&gt;
-XX:SharkPrintBitcodeOf=java.package.name::MethodName&lt;br /&gt;
use it and Shark will dump the LLVM IR bitcode to stdout just before jitting it.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;b)&lt;/b&gt; gdb call F-&gt;dump() method:&lt;br /&gt;
I personally prefer dumping LLVM IR from inside the gnu gdb debugger since this method can be used using release Shark build in combination with release llvm builds so lets jump into the gdb debugger!&lt;/p&gt;
&lt;p&gt;Start gdb and attach it to the java application with all the options that triggered the JIT CodeGen bug!&lt;br /&gt;
&lt;code&gt;$ gdb -args java -XX:CompileThreshold=1 -Xbatch -XX:+PrintCompilation JavaApplication&lt;br /&gt;
(gdb) run&lt;br /&gt;
...&lt;br /&gt;
Segmentation fault&lt;br /&gt;
$ &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Ick gdb crashed why? This are because the JVM launcher &amp;#8220;java&amp;#8221; first sets up the system environment and then forks off in a new process using execve(). gdb gets killed by the linux kernel when it are trying to read memory across process boundarys so we must stop java from forking!&lt;/p&gt;
&lt;p&gt;The easiest way to prevent java from forking are to setup the system environments before launching the application. And all this can be done from inside gdb so lets try again!&lt;br /&gt;
&lt;code&gt;$ gdb -args java -XX:CompileThreshold=1 -Xbatch -XX:+PrintCompilation JavaApplication&lt;br /&gt;
(gdb) break execve&lt;br /&gt;
Breakpoint 1 at 0x93b8&lt;br /&gt;
(gdb) run&lt;br /&gt;
(gdb) call puts(getenv(&quot;LD_LIBRARY_PATH&quot;))&lt;br /&gt;
/media/disk/4mar-shark-1.8pre-b18-llvm-2.7svn.so-npplugin/jre/lib/arm/server:/media/disk/4mar-shark-1.8pre-b18-llvm-2.7svn.so-npplugin/jre/lib/arm:/media/disk/4mar-shark-1.8pre-b18-llvm-2.7svn.so-npplugin/jre/../lib/arm&lt;br /&gt;
$1 = 220&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Ok now we know what the LD_LIBRARY_PATH should look like and if we set it before running the java launcher will prevent java from forking using execve, this &lt;a href=&quot;http://blogs.sun.com/darcy/entry/purging_ld_library_path&quot;&gt;LD_LIBRARY_PATH and execve madness are thankfully gone in JDK7&lt;/a&gt;!&lt;br /&gt;
&lt;code&gt;(gdb) set env LD_LIBRARY_PATH=/media/disk/4mar-shark-1.8pre-b18-llvm-2.7svn.so-npplugin/jre/lib/arm/server:/media/disk/4mar-shark-1.8pre-b18-llvm-2.7svn.so-npplugin/jre/lib/arm:/media/disk/4mar-shark-1.8pre-b18-llvm-2.7svn.so-npplugin/jre/../lib/arm&lt;/code&gt;&lt;br /&gt;
I will do one more thing namely set a gdb breakpoint inside java_md.c:652 right after the hotspot library libjvm.so have been loaded by the java launcher.&lt;br /&gt;
&lt;code&gt;(gdb) break java_md.c:652&lt;br /&gt;
(gdb) run&lt;br /&gt;
The program being debugged has been started already.&lt;br /&gt;
Start it from the beginning? (y or n) y&lt;br /&gt;
...&lt;br /&gt;
Breakpoint 2, LoadJavaVM ... java_md.c:652&lt;br /&gt;
652        if (libjvm == NULL) {&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This are a good spot to setup new gdb breakpoints inside the loaded libjvm.so that contains the Shark JIT. Finally we are able to place a breakpoint on the line where the Shark JIT failed inside LLVM.&lt;br /&gt;
&lt;code&gt;(gdb) break MachineFrameInfo.h:289&lt;br /&gt;
(gdb) continue&lt;br /&gt;
Continuing.&lt;br /&gt;
...&lt;br /&gt;
 10  b   java.lang.String::getChars (66 bytes)&lt;br /&gt;
 [Switching to Thread 0x67ed96a490 (LWP 21127)]&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Breakpoint 3, &amp;#8230; at &amp;#8230; MachineFrameInfo.h:289&lt;/p&gt;
&lt;p&gt;Get a backtrace and try to locate the frame where Shark calls getPointerToFunction&lt;br /&gt;
&lt;code&gt;(gdb) bt&lt;br /&gt;
...&lt;br /&gt;
#9  0x40d4ee68 in llvm::JIT::getPointerToFunction (this=0x9e138, F=0xda6f0)&lt;br /&gt;
...&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Switch to the getPointerToFunction stack frame&lt;br /&gt;
&lt;code&gt;(gdb) frame 9&lt;/code&gt;&lt;br /&gt;
and finnaly dump the LLVM IR for the function by calling the functions own method dump() !&lt;br /&gt;
&lt;code&gt;(gdb) call F-&gt;dump()&lt;br /&gt;
define internal void @&quot;java.lang.String::getChars&quot;([84 x i8]* %method, i32 %base_pc, [788 x i8]* %thread) {&lt;br /&gt;
  %1 = getelementptr inbounds [788 x i8]* %thread, i32 0, i32 756 ;  [#uses=1]&lt;br /&gt;
  %zero_stack = bitcast i8* %1 to [12 x i8]*      ; [12 x i8]*&gt; [#uses=1]&lt;br /&gt;
  %2 = getelementptr inbounds [12 x i8]* %zero_stack, i32 0, i32 8 ;  [#uses=1]&lt;br /&gt;
  %stack_pointer_addr = bitcast i8* %2 to i32*    ;  [#uses=1]&lt;br /&gt;
  %3 = load i32* %stack_pointer_addr              ;  [#uses=1]&lt;br /&gt;
&amp;#8230;&lt;br /&gt;
  %142 = getelementptr inbounds [17 x i32]* %frame, i32 0, i32 12 ;  [#uses=1]&lt;br /&gt;
  store i32 %31, i32* %142&lt;br /&gt;
  call void inttoptr (i32 13839116 to void ([788 x i8]*, i32)*)([788 x i8]* %thread, i32 7)&lt;br /&gt;
  ret void&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Horray! we have successfully dumped the Shark generated LLVM IR for the problematic method-call. Now simply copy the dump output from the terminal into a file named bug.ll and continue reading.&lt;/p&gt;
&lt;p&gt;
&lt;b&gt; Check for LLVM CodeGen bugs by testing if the dumped LLVM IR bug.ll file can reproduce the bug using llc&lt;/b&gt;&lt;br /&gt;
After you have extracted LLVM IR for the problematic method check if you can reproduce the bug  using llc..&lt;br /&gt;
&lt;code&gt;$ llvm-as &amp;lt; bug.ll | llc&lt;br /&gt;
    .syntax unified&lt;br /&gt;
    .eabi_attribute 20, 1&lt;br /&gt;
    .eabi_attribute 21, 1&lt;br /&gt;
    .eabi_attribute 23, 3&lt;br /&gt;
    .eabi_attribute 24, 1&lt;br /&gt;
    .eabi_attribute 25, 1&lt;br /&gt;
    .file    &quot;&amp;#8221;&lt;br /&gt;
llc:&lt;br /&gt;
/wd/buildbot/llvm-arm-linux/llvm/include/llvm/CodeGen/MachineFrameInfo.h:289:&lt;br /&gt;
int64_t llvm::MachineFrameInfo::getObjectOffset(int) const: Assertion&lt;br /&gt;
`!isDeadObjectIndex(ObjectIdx) &amp;#038;&amp;#038; &amp;#8220;Getting frame offset for a dead object?&amp;#8221;&amp;#8216;&lt;br /&gt;
failed.&lt;br /&gt;
0  llc       0&amp;#215;01368414&lt;br /&gt;
1  llc       0&amp;#215;01368ccc&lt;br /&gt;
2  libc.so.6 0&amp;#215;4021cc10 __default_sa_restorer_v2 + 0&lt;br /&gt;
Stack dump:&lt;br /&gt;
0.    Program arguments: /wd/r96575/Debug/bin/llc -march=arm&lt;br /&gt;
1.    Running pass &amp;#8216;Prolog/Epilog Insertion &amp;#038; Frame Finalization&amp;#8217; on function&lt;br /&gt;
&amp;#8216;@&amp;#8221;java.lang.String::getChars&amp;#8221;&amp;#8216;&lt;br /&gt;
Aborted&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If it crashes using llc then cheer up because you now got a reproducable CodeGen bug and thats great! These kind of crash bugs are on LLVM developers top wanted list because they can fire on any tool that uses LLVM code generation. The best way to report this kind of bugs are to first generate a compact testcase for LLVM that triggers the bug that can be used by the LLVM developers to fix it. It can also be run by the LLVM developers daily regression testing to make sure this bug never hits again.&lt;/p&gt;
&lt;p&gt;If it fails to crash with an Aborted like above then you are probably observing a JIT CodeEmitter runtime bug, stay tuned and look forward to my next blog post on &amp;#8220;How to fix Shark LLVM JIT CodeEmitter bugs&amp;#8221;!&lt;br /&gt;
&lt;br /&gt;&lt;b&gt;How to generate a &lt;b&gt;bugpoint-reduced-simplified.bc&lt;/b&gt; from the bug.ll using &lt;b&gt;bugpoint&lt;/b&gt; for CodeGen crash bugs&lt;/b&gt;&lt;br /&gt;
LLVM ships with a clever tool called &lt;a href=&quot;http://llvm.org/docs/Bugpoint.html&quot;&gt;bugpoint&lt;/a&gt; that are designed to convert dumped blocks of LLVM IR into a compact bugpoint-reduced-simplified.bc LLVM bitcode testcase file that only contains the instructions needed to reproduce the bug.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$ bugpoint -run-llc bug.ll --tool-args -march=arm&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Bugpoint work by using deductive logic to break down and remove parts of the bug.ll file and automatically narrow down the LLVM IR lines needed to reproduce the bug. It can take some minutes so be patient but bugpoint will eventually stop and give you a bugpoint-reduced-simplified.bc and print some information on how to reproduce the bug.&lt;/p&gt;
&lt;p&gt;
&lt;b&gt;File a LLVM bugreport containing the bugpoint-reduced-simplified.bc file&lt;/b&gt;&lt;br /&gt;
An example of a Shark JIT LLVM bug that have been fixed after submitting a bugpoint-reduced-simplified.bc produced from a dumped Shark metod are :&lt;br /&gt;
&lt;a href=&quot;http://llvm.org/bugs/show_bug.cgi?id=6478&quot;&gt;LLVM PR6478 ARM CodeGen Running pass &amp;#8216;Prolog/Epilog Insertion &amp;#038; Frame Finalization&amp;#8217; on function &amp;#8216;@&amp;#8221;java.lang.String::getChars&amp;#8221;&amp;#8216; &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I hope this post have given you some inspiration on how to get Shark LLVM JIT CodeGen crash bugs fixed!&lt;br /&gt;
If you want to know more about how bugpoint works and how to officially prepare LLVM bugreports then take a peek at the LLVM documentation: &lt;a href=&quot;http://llvm.org/docs/HowToSubmitABug.html&quot;&gt;http://llvm.org/docs/HowToSubmitABug.html&lt;/a&gt; its great.&lt;/p&gt;
&lt;p&gt;Xerxes&lt;/p&gt;</description>
	<pubDate>Wed, 10 Mar 2010 16:57:10 +0000</pubDate>
</item>
<item>
	<title>Xerxes Rånby: LLVM JIT CPU autotuner patch in limbo</title>
	<guid>http://labb.zafena.se/?p=337</guid>
	<link>http://labb.zafena.se/?p=337</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://labb.zafena.se/wp-content/uploads/2010/03/sharkjitautocpufeaturesopt.png&quot;&gt;&lt;img class=&quot;alignright size-full wp-image-338&quot; title=&quot;Shark LLVM JIT on ARM Cortex-A8 using automatic CPU features tuning passes CaffeineMark 3.0 2000 points score mark.&quot; src=&quot;http://labb.zafena.se/wp-content/uploads/2010/03/sharkjitautocpufeaturesopt.png&quot; alt=&quot;&quot; width=&quot;435&quot; height=&quot;299&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
I have from time to time been working on a automatic CPU feature tuning code for Shark to make the LLVM JIT generate better code for Cortex-A8 class ARM CPUs. Using it i was able to gain some substantial speed-improvements, all in all it made Shark generate 30% faster code on ARM and the Shark JIT are now able to beat the 2000 point CaffeineMark 3.0 score! I could not resist using CaffeineMark 3.0 for some benchmarking again &lt;img src=&quot;http://labb.zafena.se/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt; .&lt;/p&gt;
&lt;p&gt;While this looks all great with rainbows and unicorns the patch are sadly in limbo. I have had some trouble merging the code into LLVM 2.7 trunk before the next LLVM release since I got hit by &lt;a href=&quot;http://www.llvm.org/bugs/show_bug.cgi?id=6544&quot;&gt;LLVM problem report 6544&lt;/a&gt; that will force me to redesign the implementation on top of LLVM before it can be commited.&lt;/p&gt;
&lt;p&gt;And a similar optimisation like what i did for ARM Linux  can easily be done for Shark on PPC Linux as well by adopting the ARM CPU features detection code from ARM to PPC!&lt;br /&gt;
For those who are interested the optimising code are submitted and can be fetched from &lt;a href=&quot;http://www.llvm.org/bugs/show_bug.cgi?id=5389&quot;&gt;LLVM PR5389&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Cheers and have a great day!&lt;br /&gt;
Xerxes&lt;/p&gt;</description>
	<pubDate>Tue, 09 Mar 2010 15:28:11 +0000</pubDate>
</item>
<item>
	<title>Mario Torre: Nested functions</title>
	<guid>http://www.jroller.com/neugens/entry/nested_functions5</guid>
	<link>http://www.jroller.com/neugens/entry/nested_functions5</link>
	<description>Funny thing in C that I discovered today and thought I would share.

I found out that is not only possible to declare a function in the scope of another one, but also to define it, at least with GCC (I think this is a language extension, not sure if some &quot;later&quot; standard like c99 officially supports it).

Of course, this uber cool feature just makes code more funny, but it may have it's own uses (other than writing obfuscated code, I mean :)

Here is some code:

&lt;pre&gt;
int main(void)
{
    void testMe(void)
    {
        fprintf(stderr, &quot;b0rk3d!\n&quot;);
    }
    testMe();

    return (EXIT_SUCCESS);
}
&lt;/pre&gt;

without optimisations, gcc creates a regular function call, with optimisation I guess it depends on how often you use it, but this simple test gets (unsurprisingly, I guess) inlined.

Very cool :)</description>
	<pubDate>Fri, 05 Mar 2010 16:04:11 +0000</pubDate>
</item>
<item>
	<title>Roman Kennke: Beatles Review: A Hard Day’s Night</title>
	<guid>http://rkennke.wordpress.com/?p=309</guid>
	<link>http://rkennke.wordpress.com/2010/03/04/beatles-review-a-hard-days-night/</link>
	<description>&lt;p&gt;Now we come to the first peak in The Beatles&amp;#8217; career: their 3rd album &lt;a href=&quot;http://www.lastfm.de/music/The+Beatles/A+Hard+Day%27s+Night&quot;&gt;A Hard Day&amp;#8217;s Night&lt;/a&gt;. Somewhere I&amp;#8217;ve read that this album sounds like somebody opened a bottle of champaign, and this hits the nail on its head. Where the last album &lt;a href=&quot;http://rkennke.wordpress.com/2010/02/24/beatles-review-with-the-beatles/&quot;&gt;With The Beatles&lt;/a&gt; was slightly dark, this here is all bright, hyperactive and full of adrenaline. It starts with the weird opening chord (which &lt;a href=&quot;http://www.scientificblogging.com/news_releases/beatles_unknown_hard_days_night_chord_mystery_solved_using_fourier_transform&quot;&gt;puzzled even scientists&lt;/a&gt; because nobody was able to find out exactly what chord it was until 2008) of the title song, and runs through a set of 13 Beatles originals (yeah right, no cover versions this time). It shows all the good qualities of the early Beatles, their incredible vocal harmonies, their simple-yet-intriguing melodies and rhythms. And it shows the incredible fun and energy that the guys had.&lt;/p&gt;
&lt;p&gt;I remember a fun little story. When I was young (much younger than now at least), I saved myself a lot of money (around 30 DM, approx. 15€ nowadays) to buy this album on CD. That must have been in 1992 or so, I was about 14. I didn&amp;#8217;t even have a CD player! So I went to the closest supermarket, gave away my hard-earned money to get this CD. And when I was home and saw &amp;#8216;Mono&amp;#8217; on the package, I was so disappointed, because I believed that this was a fake thing. In my childish view I assumed that the real thing must be stereo because stereo is obviously better, no? In the end, I went back to the supermarket and returned the CD (that was quite a funny and geeky argument with the salesguy, not wanting the CD because it&amp;#8217;s mono). But not without first going to a friend and making a copy of it to cassette tape. Yay &lt;img src=&quot;http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif&quot; alt=&quot;:-D&quot; class=&quot;wp-smiley&quot; /&gt;  Only much later I realized that the mono version was indeed the official version and bought the CD again. Now I have both, and comparing the versions I must say that the mono version is indeed better, again there are a bunch of glitches on stereo (the start of &amp;#8216;Should Have Known Better&amp;#8217; for example) that have been corrected in mono. It needs to be said that at this time mono was by far the dominant format and the Beatles themselves never really cared for the stereo mixes, leaving them to others, while attending the mono mixes themselves. However, compared to the first two albums, which have this funny extreme left-right panning, the stereo mixes are a bit more sane, which owes to the fact that they used 4 track recording for the first time.&lt;/p&gt;
&lt;p&gt;That was a bit technical this time, I usually try to avoid that because we want to listen to music, not technology, right? I enjoyed listening to this album today anyway. Quite alot even. Next time I will have a look (listen) at the Beatles for Sale.&lt;/p&gt;
&lt;br /&gt;  &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gocomments/rkennke.wordpress.com/309/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/rkennke.wordpress.com/309/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godelicious/rkennke.wordpress.com/309/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/rkennke.wordpress.com/309/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gostumble/rkennke.wordpress.com/309/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/rkennke.wordpress.com/309/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godigg/rkennke.wordpress.com/309/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/rkennke.wordpress.com/309/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/goreddit/rkennke.wordpress.com/309/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/rkennke.wordpress.com/309/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://stats.wordpress.com/b.gif?host=rkennke.wordpress.com&amp;blog=9951657&amp;post=309&amp;subd=rkennke&amp;ref=&amp;feed=1&quot; /&gt;rkennke</description>
	<pubDate>Thu, 04 Mar 2010 23:18:25 +0000</pubDate>
</item>
<item>
	<title>Andrew Hughes: IcedTea6 1.7.1 Released!</title>
	<guid>http://blog.fuseyism.com/?p=95</guid>
	<link>http://blog.fuseyism.com/index.php/2010/02/26/icedtea6-171-released/</link>
	<description>&lt;p&gt;We are pleased to announce the release of IcedTea6 1.7.1!&lt;/p&gt;
&lt;p&gt;The IcedTea project provides a harness to build the source code from&lt;br /&gt;
OpenJDK6 using Free Software build tools. It also includes the only&lt;br /&gt;
Free Java plugin and Web Start implementation, and support for&lt;br /&gt;
additional architectures over and above x86, x86_64 and SPARC via the&lt;br /&gt;
Zero assembler port.&lt;/p&gt;
&lt;h2&gt;What&amp;#8217;s New?&lt;/h2&gt;
&lt;h3&gt;Bug fixes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=179&quot;&gt;PR179&lt;/a&gt;: Rhino bootclasspath issue&lt;/li&gt;
&lt;li&gt;Add missing .c file to PulseAudio build&lt;/li&gt;
&lt;li&gt;Zero/Shark
&lt;ul&gt;
&lt;li&gt;Formatting changes and other fixes to match upstream&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=428&quot;&gt;PR428&lt;/a&gt;: Shark on ARM precompiled header incls&lt;/li&gt;
&lt;li&gt;Update Shark for LLVM r95390 API change.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6927165&quot;&gt;S6927165&lt;/a&gt;: Zero S/390 fixes (from upstream)&lt;/li&gt;
&lt;li&gt;Implemented Shark host CPU feature autotuner using LLVM 2.7 APIs.&lt;/li&gt;
&lt;li&gt;Add s390 support to TCK setup helper script&lt;/li&gt;
&lt;li&gt;Strip stupid options that llvm-config supplies&lt;/li&gt;
&lt;li&gt;Update Shark for LLVM r94686 API change.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6914622&quot;&gt;S6914622&lt;/a&gt;, &lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6909153&quot;&gt;S6909153&lt;/a&gt;, &lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6913869&quot;&gt;S6913869&lt;/a&gt; upstream Zero fixes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;NPPlugin fixes
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=446&quot;&gt;PR446&lt;/a&gt;: Use JDK_UPDATE_VERSION to set the jpi version.&lt;/li&gt;
&lt;li&gt;Re-designed frame embedding code so that the applet is dynamically packed into given handle. This increases stability and breaks reliance on the assumption that the browser will always provide a handle in a certain sequence.&lt;/li&gt;
&lt;li&gt;Encode new lines, carriage returns, and other special characters before sending them to Java side (de-coding code is already in effect on the Java side).&lt;/li&gt;
&lt;li&gt;Centralised and increased timeouts to give slow-loading applets enough time to load.&lt;/li&gt;
&lt;li&gt;Fix security permissions related to get/set property, based on specifications.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The tarball can be downloaded from:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://icedtea.classpath.org/download/source/icedtea6-1.7.1.tar.gz&quot;&gt;http://icedtea.classpath.org/download/source/icedtea6-1.7.1.tar.gz&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The following people helped with the 1.7 release series:&lt;/p&gt;
&lt;p&gt;Lillian Angel, Gary Benson, Deepak Bhole, Andrew Haley, Andrew John Hughes, Nobuhiro Iwamatsu, Matthias Klose, Martin Matejovic, Edward Nevill, Xerxes Rånby, Robert Schuster,Jon VanAlten, Mark Wielaard and Man Lung Wong.&lt;/p&gt;
&lt;p&gt;We would also like to thank the bug reporters and testers!&lt;/p&gt;
&lt;p&gt;To get started:&lt;/p&gt;
&lt;pre&gt;
$ tar xzf icedtea6-1.7.1.tar.gz
$ cd icedtea6-1.7.1
&lt;/pre&gt;
&lt;p&gt;Full build requirements and instructions are in INSTALL:&lt;/p&gt;
&lt;pre&gt;
$ ./configure [--enable-visualvm --with-openjdk --enable-pulse-java
--enable-systemtap ...]
$ make
&lt;/pre&gt;</description>
	<pubDate>Fri, 26 Feb 2010 17:52:18 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: Notions of Floating-Point Equality</title>
	<guid>http://blogs.sun.com/darcy/entry/notions_of_floating_point_equality</guid>
	<link>http://blogs.sun.com/darcy/entry/notions_of_floating_point_equality</link>
	<description>&lt;p&gt;

Moving on from 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/api_design_identity_and_equality&quot; title=&quot;API Design: Identity and Equality&quot;&gt;identity and equality of objects&lt;/a&gt;, different notions of equality are also surprisingly subtle in some numerical realms.

&lt;/p&gt;

&lt;p&gt;

As &lt;a href=&quot;http://mail.openjdk.java.net/pipermail/nio-dev/2009-November/000792.html&quot; title=&quot;Nov. 2009 nio-dev thread on DoubleBuffer.compareTo is not anti-symmetric&quot;&gt;comes up from time to time&lt;/a&gt; and is often surprising, the &quot;&lt;code&gt;==&lt;/code&gt;&quot; operator defined by IEEE 754 and used by Java for comparing floating-point values 
(&lt;a href=&quot;http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.21.1&quot; title=&quot;Numerical Equality Operators == and !=&quot;&gt;JLSv3 &amp;sect;15.21.1&lt;/a&gt;)
is &lt;em&gt;not&lt;/em&gt; an &lt;i&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Equivalence_relation&quot;&gt;equivalence relation&lt;/a&gt;&lt;/i&gt;.  Equivalence relations satisfy three properties, reflexivity (something is equivalent to itself), symmetry (if &lt;i&gt;a&lt;/i&gt; is equivalent to &lt;i&gt;b&lt;/i&gt;, &lt;i&gt;b&lt;/i&gt; is equivalent to &lt;i&gt;a&lt;/i&gt;), and transitivity (if &lt;i&gt;a&lt;/i&gt; is equivalent to &lt;i&gt;b&lt;/i&gt; and &lt;i&gt;b&lt;/i&gt; is equivalent to &lt;i&gt;c&lt;/i&gt;, then &lt;i&gt;a&lt;/i&gt; is equivalent to &lt;i&gt;c&lt;/i&gt;).

&lt;/p&gt;

&lt;p&gt;

The IEEE 754 standard defines four possible mutually exclusive  
ordering relations between floating-point values:&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt;&lt;p&gt;equal
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;greater than
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;less than
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;unordered
&lt;/p&gt;

&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;

A NaN (Not a Number) is &lt;em&gt;unordered&lt;/em&gt; with respective to every floating-point value, 
including itself.  This was done so that NaNs would not quietly slip by without due notice.  Since (NaN == NaN) is false, the IEEE 754 &quot;&lt;code&gt;==&lt;/code&gt;&quot; relation is &lt;em&gt;not&lt;/em&gt; an equivalence relation since it is not reflexive.

&lt;/p&gt;

&lt;p&gt;

An equivalence relation partitions a set into equivalence classes; each member of an equivalence classes is &quot;the same&quot; as the other members of the classes for the purposes of that equivalence relation.  In terms of numerics, one would expect equivalent values to result in equivalent numerical results in all cases.  Therefore, the size of the equivalence classes over floating-point values would be expected to be one; a number would only be equivalent to itself.  However, in IEEE 754 there are two zeros, -0.0 and +0.0, and they compare as equal under &lt;code&gt;==&lt;/code&gt;.  For IEEE 754 addition and subtraction, the sign of a zero argument can at most affect the sign of a zero result.  That is, if the sum or difference is not zero, a zero of either sign doesn't change the result.  If the sum or differnece is zero and one of the arguments is zero, the other argument must be zero too:

&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt;&lt;p&gt;-0.0 + -0.0 &amp;rArr; -0.0
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;-0.0 + +0.0 &amp;rArr; +0.0
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;+0.0 + -0.0 &amp;rArr; +0.0
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;+0.0 + +0.0 &amp;rArr; +0.0
&lt;/p&gt;

&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;

Therefore, under addition and subtraction, both signed zeros are equivalent.  However, they are &lt;em&gt;not&lt;/em&gt; equivalent under division since 1.0/&lt;b&gt;-&lt;/b&gt;0.0  &amp;rArr; 
-&amp;#8734;  but 1.0/&lt;b&gt;+&lt;/b&gt;0.0 &amp;rArr; +&amp;#8734;  and -&amp;#8734;  and +&amp;#8734; are &lt;em&gt;not&lt;/em&gt; equivalent.&lt;a href=&quot;http://blogs.sun.com/darcy/feed/entries/rss#affine&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt;

&lt;/p&gt;

&lt;p&gt;

Despite the rationales for the IEEE 754 specification to not define &lt;code&gt;==&lt;/code&gt; as an equivalence relation, there are legitimate cases where one needs a true equivalence relation over floating-point values, such as when writing test programs, and cases where one needs a total ordering, such as when sorting.  In my numerical tests I use a method 
that returns &lt;code&gt;true&lt;/code&gt; for two floating-point values &lt;i&gt;x&lt;/i&gt; and &lt;i&gt;y&lt;/i&gt; if:&lt;br /&gt;

((&lt;i&gt;x&lt;/i&gt; == &lt;i&gt;y&lt;/i&gt;) &amp;amp;&amp;amp;&lt;br /&gt;
 (if &lt;i&gt;x&lt;/i&gt; and &lt;i&gt;y&lt;/i&gt; are both zero they have the same sign)) || &lt;br /&gt;
(x and y are both NaN)&lt;br /&gt;

Conveniently, this is just computed by using &lt;code&gt;(Double.compare(x, y) == 0)&lt;/code&gt;.  For sorting or a total order, the semantics of &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Double.html#compare(double,%20double)&quot;&gt;&lt;code&gt;Double.compare&lt;/code&gt;&lt;/a&gt; are fine; NaN is treated as being the largest floating-point values, greater than positive infinity, and -0.0  +0.0.  That ordering is the total order used by by &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#sort(double[])&quot;&gt;&lt;code&gt;java.util.Arrays.sort(double[])&lt;/code&gt;&lt;/a&gt;.  In terms of semantics, it doesn't really matter where the NaNs are ordered with respect to ther values to as long as they are consistently ordered that way.&lt;sup&gt;&lt;a href=&quot;http://blogs.sun.com/darcy/feed/entries/rss#bitwise&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;

&lt;/p&gt;

&lt;p&gt;

These subtleties of floating-point comparison were also germane on the Project Coin mailing list last year; the &lt;a href=&quot;http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/000566.html&quot;&gt;definition of floating-point equality was discussed in relation to adding support for relational operations based on a type implementing the &lt;code&gt;Comparable&lt;/code&gt; interface&lt;/a&gt;.  That thread also broached the complexities involved in comparing &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html&quot;&gt;BigDecimal&lt;/a&gt;&lt;/p&gt; values.



&lt;p&gt;

The &lt;code&gt;BigDecimal&lt;/code&gt; class has a natural ordering that is &lt;em&gt;inconsistent with equals&lt;/em&gt;; that is for at least some inputs &lt;code&gt;bd1&lt;/code&gt; and &lt;code&gt;bd2&lt;/code&gt;, &lt;br /&gt;
&lt;code&gt;c.compare(bd1, bd2)==0&lt;/code&gt;&lt;br /&gt;
has a different boolean value than&lt;br /&gt;
&lt;code&gt;bd1.equals(bd2)&lt;/code&gt;.&lt;sup&gt;&lt;a href=&quot;http://blogs.sun.com/darcy/feed/entries/rss#consistent&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;br /&gt;

In &lt;code&gt;BigDecimal&lt;/code&gt;, the same numerical value can have multiple representations, such as (100 &amp;times; 10&lt;sup&gt;0&lt;/sup&gt;) versus (10 &amp;times; 10&lt;sup&gt;1&lt;/sup&gt;) versus (1 &amp;times; 10&lt;sup&gt;2&lt;/sup&gt;).  These are all &quot;the same&quot; numerically (&lt;code&gt;compareTo == 0&lt;/code&gt;) but are &lt;em&gt;not&lt;/em&gt; &lt;code&gt;equals&lt;/code&gt; with each other.  Such values are not equivalent under the operations supported by &lt;code&gt;BigDecimal&lt;/code&gt;; for example (100 &amp;times; 10&lt;sup&gt;0&lt;/sup&gt;) has a &lt;i&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html#scale()&quot;&gt;scale&lt;/a&gt;&lt;/i&gt; of 0 while (1 &amp;times; 10&lt;sup&gt;2&lt;/sup&gt;) has a scale of -2.&lt;sup&gt;&lt;a href=&quot;http://blogs.sun.com/darcy/feed/entries/rss#cohort&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;

&lt;/p&gt;

&lt;p&gt;

While subtle, the different notions of numerical equality each serve a useful purpose and knowing which notion is appropriate for a given task is an important factor in writing correct programs.

&lt;/p&gt;

&lt;hr width=&quot;50%&quot; /&gt;

&lt;blockquote&gt;
&lt;p&gt;
&lt;a name=&quot;affine&quot;&gt;&lt;sup&gt;1&lt;/sup&gt;&lt;/a&gt; There are two zeros in IEEE 754 
because there are two infinities.  Another way to extend the real numbers to include infinity is to have a single (unsigned) projective infinity.  In 
such a system, there is only one conceptual zero.  Early x87 chips before IEEE 754 
was standardized had support for both signed (affine) and projective 
infinities.  Each style of infinity is more convenient for some kinds of computations.
&lt;/p&gt;

&lt;p&gt;
&lt;sup&gt;&lt;a name=&quot;bitwise&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;

Besides the equivalence relation offered by &lt;code&gt;Double.compare(x, y)&lt;/code&gt;, another equivalence relation can be induced by either of the bitwise conversion routines, &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits(double)&quot;&gt;Double.doubleToLongBits&lt;/a&gt; or &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToRawLongBits(double)&quot;&gt;Double.doubleToRawLongBits&lt;/a&gt;.  The former collapses all bit patterns that encode a NaN value into a single canonical NaN bit pattern, while the latter can let through a platform-specific NaN value.  Implementation freedoms allowed by the original IEEE 754 standard have allowed different processor families to define different conventions for NaN bit patterns. 

&lt;/p&gt;

&lt;p&gt;
&lt;sup&gt;&lt;a name=&quot;consistent&quot;&gt;3&lt;/a&gt;&lt;/sup&gt; I've at times considered whether it would be worthwhile to include an &quot;&lt;code&gt;@NaturalOrderingInconsistentWithEquals&lt;/code&gt;&quot; annotation in the platform to flag the classes that have this quirk.  Such an annotation could be used by various checkers to find potentially problematic uses of such classes in sets and maps.
&lt;/p&gt;

&lt;p&gt;
&lt;sup&gt;&lt;a name=&quot;cohort&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; Building on wording developed for the &lt;code&gt;BigDecimal&lt;/code&gt; specification under &lt;a href=&quot;http://jcp.org/en/jsr/detail?id=13&quot;&gt;JSR 13&lt;/a&gt;, when I was editor of the &lt;a href=&quot;http://en.wikipedia.org/wiki/IEEE_754-2008&quot;&gt;IEEE 754 revision&lt;/a&gt;, I introduced several pieces of decimal-related terminology into the draft.  Those terms include &lt;i&gt;preferred exponent&lt;/i&gt;, analogous to the preferred scale from &lt;code&gt;BigDecimal&lt;/code&gt;, and &lt;i&gt;cohort&lt;/i&gt;, &quot;The set of all floating-point representations that represent a given floating-point number in a
given floating-point format.&quot;  Put in terms of &lt;code&gt;BigDecimal&lt;/code&gt;, the members of a cohort would be all the &lt;code&gt;BigDecimal&lt;/code&gt; numbers with the same numerical value, but distinct pairs of scale (negation of the exponent) and unscaled value.

&lt;/p&gt;

&lt;/blockquote&gt;</description>
	<pubDate>Fri, 26 Feb 2010 09:00:00 +0000</pubDate>
</item>
<item>
	<title>Xerxes Rånby: Sharks and thumbs sighted in various cool constalations</title>
	<guid>http://labb.zafena.se/?p=316</guid>
	<link>http://labb.zafena.se/?p=316</link>
	<description>&lt;p&gt;During the past months i have seen some really cool stuff done using small powerefficient ARM computers and OpenJDK.&lt;/p&gt;
&lt;div id=&quot;attachment_318&quot; class=&quot;wp-caption alignright&quot; style=&quot;width: 235px&quot;&gt;&lt;a href=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/simplesimon-connects.jpg&quot;&gt;&lt;img class=&quot;size-medium wp-image-318&quot; title=&quot;simplesimon-connects&quot; src=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/simplesimon-connects.jpg&quot; alt=&quot;SimpleSimon connects&quot; width=&quot;225&quot; height=&quot;300&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;Simple Simon PT connected to a hospital laboratory system by using a powerefficient plugcomputer and displaylink usb screen. All powered by OpenJDK&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Simple Simon PT connects:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This project hooks up a battery powered laboratory coagulation device, a Simple Simon PT reader to standard hospital laboratory system using a ASTM-1394-1397 / LIS2-A2 connectivity over ethernet. A small ARM based plugcomputer does all data message processing and communication. User interraction are performed by using the Simon reader and a usb-barcode reader to enter laboratory identification. Optionally can a usb-touch-screen be connected for improved user feedback, by displaying charts using JFreeChart, to show and give a better understanding of the coagulation process.&lt;/p&gt;
&lt;p&gt;Powerconsumption tops at 15W with the USB screen attached and 6W without. All running silent without any moving parts!&lt;/p&gt;
&lt;div id=&quot;attachment_317&quot; class=&quot;wp-caption alignnone&quot; style=&quot;width: 310px&quot;&gt;&lt;a href=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/shark-linked-against-shared-libllvm27svso.jpg&quot;&gt;&lt;img class=&quot;size-medium wp-image-317&quot; title=&quot;shark-linked-against-shared-libllvm27svso&quot; src=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/shark-linked-against-shared-libllvm27svso.jpg&quot; alt=&quot;Shark linked against the shared libLLVM-2.7svn.so&quot; width=&quot;300&quot; height=&quot;225&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;Shark linked against the shared libLLVM-2.7svn.so&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Shark linked against dynamic LLVM .so library&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Earlier today I got Shark linked against a shared libLLVM-2.7svn.so generated by using LLVM 2.7svn trunk. It work by simply building LLVM using configure &amp;#8211;enable-shared &amp;#8211;enable-optimized &amp;#8211;disable-assertions and then tweak the Icedtea6 main Makefiles to use the shared library during liking:&lt;br /&gt;
Replace the line&lt;br /&gt;
&lt;code&gt;LLVM_LIBS = -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMMCParser -lLLVMX86AsmPrinter -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Info -lLLVMJIT -lLLVMExecutionEngine -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMCore -lLLVMSupport -lLLVMSystem&lt;/code&gt;&lt;br /&gt;
with&lt;br /&gt;
&lt;code&gt;LLVM_LIBS = -lLLVM-2.7svn&lt;/code&gt;&lt;br /&gt;
in the main icedtea6/Makefile and then build Icedtea6 normally, Shark currently builds and works right out of the box when using a LLVM release build!&lt;/p&gt;
&lt;p&gt;A cool thing by building shark against the shared library are that you can switch the LLVM JIT that Shark uses from running with or without assertions, debug code, and various extra optimizations by simply replacing the /usr/local/lib/libLLVM-2.7svn.so file with what you want. Linking time during shark builds and shark footprint are impressively smaller as well. Im really happy to see this functionallity in LLVM 2.7!&lt;/p&gt;
&lt;p&gt;The LLVM 2.7 code freeze before the 2.7 release happens in about 1.5 weeks from now and i will stay busy for some days to observe and polish the current LLVM svn trunk to be usable with openjdk-6-shark.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edward Nevill created a ARM Jazelle RTC Thumb2 JIT reference implementation&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Meanwhile I have been busy taming Sharks a new kind of Thumb2 JIT have emerged built by Edward Nevill of Cambridge Software Labs! The new Tumb2JIT have been committed into the Icedtea6 trunk and it are a working implementation of Jazelle RTC to be used by ARM Cortex-A8+ class CPUs. It wonderfull that this have been released as free software, Wow!,&lt;/p&gt;
&lt;p&gt;Suddenly we got three different JITs to use on ARM with OpenJDK: Cacao, Shark and T2. An opurtunity has emerged to tier them and so I did. Here comes the raw &amp;#8220;truth&amp;#8221; produced by Caffeine Mark 3! This will probably be the last time i will show off any Caffeine Mark 3 benchmark since it really dont give justice on real world client applications where responsiveness are more crucial than top runtime speed, nevertheless benchmarking using CM30 have always felt fun so here we go: All benchmarks running using a Sharp PC-Z1 Cortex-A8 Mobile internet tool.&lt;/p&gt;
&lt;div id=&quot;attachment_328&quot; class=&quot;wp-caption alignnone&quot; style=&quot;width: 1314px&quot;&gt;&lt;a href=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/tier-t2-shark-cacao.png&quot;&gt;&lt;img class=&quot;size-full wp-image-328&quot; title=&quot;tier-t2-shark-cacao&quot; src=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/tier-t2-shark-cacao.png&quot; alt=&quot;Tier between Edwards Thumb 2 JIT , Shark LLVM JIT and Cacao JIT: All running on OpenJDK 6 ARM&quot; width=&quot;1304&quot; height=&quot;299&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;Tier between Edwards Thumb 2 JIT , Shark LLVM JIT and Cacao JIT: All running on a ARM Sharp PC-Z1 Mobile internet tool smartbook using OpenJDK 6 compiled with Icedtea6.&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;This new T2 JIT&amp;#8217;s main strenght are reduced jitting time, it basically cuts all jtting time to almost zero and client applications on ARM finnaly runs from tick one. This thumb2 jit makes a really nice java applet browser experience with about 15 seconds first applet startuptime on a ARM smartbook and and all usable instantly after being loaded.&lt;br /&gt;
&lt;a href=&quot;http://labb.zafena.se/wp-content/uploads/2010/02/java-applets-on-sharp-pc-z1-featuring-the-new-t2jit.3gp&quot;&gt;A small 1min 12seconds .3gp movie displaying some java applets running on the Sharp PC-Z1 featuring the new thumb2jit from Icedtea6&lt;br /&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cheers and have a great day!&lt;br /&gt;
Xerxes&lt;/p&gt;</description>
	<pubDate>Thu, 25 Feb 2010 19:43:26 +0000</pubDate>
</item>
<item>
	<title>Christian Thalinger (Adv): First invokedynamic call on SPARC</title>
	<guid>http://blogs.sun.com/twisti/entry/first_invokedynamic_call_on_sparc</guid>
	<link>http://www.advogato.org/person/twisti/diary.html?start=35</link>
	<description>&lt;p&gt;Today I successfully executed an invokedynamic call on SPARC for the first time.&amp;nbsp; Excellent!&lt;/p&gt; 
  &lt;pre&gt;$ bin/jruby.gamma -J-XX:+UseSerialGC -J-Djruby.compile.invokedynamic=true -J-Xint -J-XX:+UnlockExperimentalVMOptions -J-XX:+EnableMethodHandles -J-XX:+EnableInvokeDynamic bench/bench_fib_recursive.rb 
OpenJDK Server VM (17.0-b08-internal-jvmg) for solaris-sparc JRE (1.7.0), built on Feb 25 2010 04:35:47 by &quot;ct232829&quot; with Workshop 5.9
VM option '+UseSerialGC'
VM option '+UnlockExperimentalVMOptions'
VM option '+EnableMethodHandles'
VM option '+EnableInvokeDynamic'
 52.813000   0.000000  52.813000 ( 52.296000)
 52.824000   0.000000  52.824000 ( 52.823000)
 51.808000   0.000000  51.808000 ( 51.808000)
 49.740000   0.000000  49.740000 ( 49.740000)
 49.450000   0.000000  49.450000 ( 49.450000)
&lt;/pre&gt; 
  &lt;p&gt;MethodHandle calls already work since a couple of days and I can run the JDK &lt;a href=&quot;http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/a9b4fde406d4/test/java/dyn/MethodHandlesTest.java&quot;&gt;MethodHandlesTest&lt;/a&gt; without any errors:&lt;/p&gt; 
  &lt;pre&gt;$ gamma -Xinternalversion
OpenJDK Server VM (17.0-b08-internal-jvmg) for solaris-sparc JRE (1.7.0), built on Feb 25 2010 04:35:47 by &quot;ct232829&quot; with Workshop 5.9
$ gamma -Xint -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -classpath /java/devtools/share/junit/latest/junit.jar:. org.junit.runner.JUnitCore MethodHandlesTestVM option '+UnlockExperimentalVMOptions'
VM option '+EnableMethodHandles'
JUnit version 4.4
OpenJDK Server VM warning: JSR 292 invokedynamic is disabled in this JVM.  Use -XX:+UnlockExperimentalVMOptions -XX:+EnableInvokeDynamic to enable.
.IIIIII.findStatic
:::::::::::.findVirtual
:::::::::::::::.findSpecial
::.bind
::::::::::::::::::::::.unreflect
::::::::::::::::::::::::I.unreflectGetter
.unreflectSetter
.arrayElementGetter
.arrayElementSetter
.convertArguments
::::::.permuteArguments
.spreadArguments
.collectArguments
.insertArguments
.filterArguments
.foldArguments
.dropArguments
.exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker
.guardWithTest
.catchException
.throwException
.testCastFailure

Time: 7.984

OK (23 tests)
&lt;/pre&gt; 
  &lt;p&gt;JSR 292 SPARC support is on its way...&lt;br /&gt;&lt;/p&gt;</description>
	<pubDate>Thu, 25 Feb 2010 13:12:45 +0000</pubDate>
</item>
<item>
	<title>Roman Kennke: Beatles review: With The Beatles</title>
	<guid>http://rkennke.wordpress.com/?p=296</guid>
	<link>http://rkennke.wordpress.com/2010/02/24/beatles-review-with-the-beatles/</link>
	<description>&lt;p&gt;Let&amp;#8217;s continue the Beatles reviews that I started with &lt;a href=&quot;http://rkennke.wordpress.com/2010/02/22/beatles-review-please-please-me/&quot;&gt;Please Please Me&lt;/a&gt; with their next album: &lt;a href=&quot;http://www.lastfm.de/music/The+Beatles/With+the+Beatles&quot;&gt;With The Beatles&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I remember quite well when I first listened this album for the first time. It is one of those albums that immediately bring up the mood, smell and details of that particular situation and time in my life. I was about 11 years old (I guess) and visiting my father. He had a czech print of this album, and I listened it over his great headphone. Of course I copied it to cassette (at this point cassette and reel tape was the only source of music for me, no thinking of CDs yet). I listened it over and over again in my walkman and couldn&amp;#8217;t get enough of it. The weird hard-panned stereo mix allowed for fun experiments: if you only listen to one channel, you get voices and drums (for example) and on the other channel guitars and base, etc. Quite fun. I was a bit disappointed when I bought the CD later that it was only available in mono &amp;#8211; now I understand that the mono version is infact much better overall. Like with the first album (and the next albums as well), the stereo mixes have some glitches that were corrected in mono (listen the start of &amp;#8216;Roll Over Beethoven&amp;#8217; as an example). The album blasts off with &amp;#8216;It Won&amp;#8217;t Be Long&amp;#8217; (doing the Yeah shouting that they became famous for with their single She Loves You &amp;#8211; which did not end up on the album) and keeps the energy until the last note of &amp;#8216;Money&amp;#8217;. Compared to their first album it is slightly more complex, they added a piano (and a rumbling piano that is) and refined their sound. Where the first album was sort of a generic beat music thing, this album is definitely Beatles (in full swing of Beatlemania). They also deliver the same basic ingredients that were also present on the first album: love songs, rockers, exotic stuff, cover versions, some George and some Ringo. My favorite is probably the last song &amp;#8216;Money (that&amp;#8217;s what I want)&amp;#8217; (money seems to be a recurring theme in their career, as if they had too little: &amp;#8216;Can&amp;#8217;t Buy Me Love&amp;#8217;, &amp;#8216;Taxman&amp;#8217;, &amp;#8216;Baby You&amp;#8217;re a Rich Man&amp;#8217; and finally &amp;#8216;You Never Give Me Your Money&amp;#8217; and probably some others that I forgot). The cover of the album is also notable: instead of the happy-go-lucky photographs that was to be expected, it shows an arty black and white photo with the four in black polo neck pullovers. To me this is one of my favorite album covers of the Beatles. I really enjoyed listening this album today, it&amp;#8217;s a good album for foggy days, but apparently it also works for sunny spring days like today &lt;img src=&quot;http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:-)&quot; class=&quot;wp-smiley&quot; /&gt;  Please let me know how do you like the album in the comments below, and stay tuned for the next album &lt;a href=&quot;http://rkennke.wordpress.com/2010/03/04/beatles-review-a-hard-days-night/&quot;&gt;A Hard Day&amp;#8217;s Night&lt;/a&gt;.&lt;/p&gt;
&lt;br /&gt;  &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gocomments/rkennke.wordpress.com/296/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/rkennke.wordpress.com/296/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godelicious/rkennke.wordpress.com/296/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/rkennke.wordpress.com/296/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gostumble/rkennke.wordpress.com/296/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/rkennke.wordpress.com/296/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godigg/rkennke.wordpress.com/296/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/rkennke.wordpress.com/296/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/goreddit/rkennke.wordpress.com/296/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/rkennke.wordpress.com/296/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://stats.wordpress.com/b.gif?host=rkennke.wordpress.com&amp;blog=9951657&amp;post=296&amp;subd=rkennke&amp;ref=&amp;feed=1&quot; /&gt;rkennke</description>
	<pubDate>Wed, 24 Feb 2010 22:05:23 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: API Design: Identity and Equality</title>
	<guid>http://blogs.sun.com/darcy/entry/api_design_identity_and_equality</guid>
	<link>http://blogs.sun.com/darcy/entry/api_design_identity_and_equality</link>
	<description>&lt;p&gt;

When designing types to be reused by others, there are &lt;a href=&quot;http://blogs.sun.com/darcy/entry/api_design_interfaces_versus_abstract&quot; title=&quot;API Design: Interfaces versus Abstract Classes&quot;&gt;reasons to favor interfaces over abstract classes&lt;/a&gt;.

One complication of using an interface-based approach stems from defining reasonable behavior for the &lt;code&gt;equals&lt;/code&gt; and &lt;code&gt;hashCode&lt;/code&gt; methods, especially if different implementations are intended to play well together when used in data structures like &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/Collection.html&quot;&gt;collections&lt;/a&gt;, in particular if an interface type is meant to serve as the key of a &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/Map.html&quot;&gt;map&lt;/a&gt; or as the element type of a &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/Set.html&quot;&gt;set&lt;/a&gt;.

&lt;/p&gt;

&lt;p&gt;

Some interfaces, like &lt;code&gt;CharSequence&lt;/code&gt;, are designed to &lt;em&gt;not&lt;/em&gt; be a usable type for a map key or an element type of a set:

&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;

&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html&quot;&gt;[The &lt;code&gt;CharSequence&lt;/code&gt;] interface&lt;/a&gt; does not refine the general contracts of the &lt;code&gt;equals&lt;/code&gt; and &lt;code&gt;hashCode&lt;/code&gt; methods. The result of comparing two objects that implement &lt;code&gt;CharSequence&lt;/code&gt; is therefore, in general, undefined. Each object may be implemented by a different class, and there is no guarantee that each class will be capable of testing its instances for equality with those of the other. It is therefore inappropriate to use arbitrary &lt;code&gt;CharSequence&lt;/code&gt; instances as elements in a set or as keys in a map. 

&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;

Amongst other problems, &lt;code&gt;CharSequence&lt;/code&gt;s are not required to be immutable so  in general there are always hazards from &lt;a href=&quot;http://en.wikipedia.org/wiki/Time-of-check-to-time-of-use&quot;&gt;time of check to time of use&lt;/a&gt; conditions.  


&lt;/p&gt;

&lt;p&gt;

Even if a type is not suitable as a map key, it can be fine as the type of the &lt;em&gt;value&lt;/em&gt; to which a key gets mapped.  

Likewise, even if type cannot serve as the element type of a set, it can often still be perfectly fine as the element type of a &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/List.html&quot;&gt;list&lt;/a&gt;.

&lt;/p&gt;

&lt;p&gt;

Expanding on a slide from my JavaOne talk 
&lt;a href=&quot;http://blogs.sun.com/darcy/resource/JavaOne/J1_2008-BOF-5874.pdf&quot; title=&quot;Slides for JavaOne 2008 bof: Tips and Tricks...&quot;&gt;&lt;i&gt;Tips and Tricks for Using Language Features in API Design and Implementation&lt;/i&gt;&lt;/a&gt;, for interface types intended to be used as map keys or set elements, equality can be defined in several ways.

First, equality can be defined solely in terms of information retrievable from methods of the interface.  Alternatively, equality can be defined in terms of information retrievable via the interface methods &lt;em&gt;as well as&lt;/em&gt; additional information.  Finally, object identity (the &lt;code&gt;==&lt;/code&gt; relation) is always a valid definition for &lt;code&gt;equals&lt;/code&gt; and often a good implementation choice.

&lt;/p&gt;

&lt;p&gt;

An example of the first kind of equality definition is specified for annotation types:

&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/annotation/Annotation.html#equals(java.lang.Object)&quot;&gt;java.lang.annotation.Annotation.equals(Object)&lt;/a&gt;&lt;/code&gt;:&lt;br /&gt;
Returns true if the specified object represents an annotation that is logically equivalent to this one. In other words, returns true if the specified object is an instance of the same annotation type as this instance, all of whose members are equal to the corresponding member of this annotation, as defined below: ...
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/annotation/Annotation.html#hashCode()&quot;&gt;java.lang.annotation.Annotation.hashCode()&lt;/a&gt;&lt;/code&gt;:&lt;br /&gt;
Returns the hash code of this annotation, as defined below:&lt;br /&gt;

The hash code of an annotation is the sum of the hash codes of its members (including those with default values), as defined below:...
&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;

A consequence of defining equality in this manner is that the &lt;code&gt;hashCode&lt;/code&gt; algorithm must also be specified.  If it were not specified, the &lt;code&gt;equals&lt;/code&gt;/&lt;code&gt;hashCode&lt;/code&gt;  contract would be violated since &lt;em&gt;equal objects must have equal &lt;code&gt;hashCodes&lt;/code&gt;&lt;/em&gt;.  Therefore, different implementations of this style of interface must have enough information to implement the equals method and have a precise algorithm for &lt;code&gt;hashCode&lt;/code&gt;.

&lt;/p&gt;

&lt;p&gt;

An annotation type is a kind of interface.  At runtime, &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/reflect/Proxy.html&quot;&gt;dynamic proxies&lt;/a&gt; are used to create  the core reflection objects implementing annotation types, such as the objects returned by the
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/reflect/AnnotatedElement.html#getAnnotation(java.lang.Class)&quot;&gt;&lt;code&gt;getAnnotation&lt;/code&gt;&lt;/a&gt; method.  After a quick identity check, the equals algorithm used in the proxy sees if the annotation type of the two annotation objects is the same and then compares the results of the annotation type's methods.  This indirection allows the annotation objects from core reflection to interact properly with other implementations of annotation objects.  The annotation objects generated for annotation processing in &lt;code&gt;apt&lt;/code&gt; and &lt;code&gt;javac&lt;/code&gt; both use the same underlying implementation as core reflection.  However, completely independent annotation implementations are fine too.  For example, the code below

&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;

/**
 * Demonstrate equality of different annotation implementations.
 */
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class AnnotationEqualityDemonstration {
    static class MySupportedSourceVersion implements SupportedSourceVersion {
        private final SourceVersion sourceVersion;

        private MySupportedSourceVersion(SourceVersion sourceVersion) {
            this.sourceVersion = sourceVersion;
        }

        public Class annotationType() {
            return SupportedSourceVersion.class;
        }

        public SourceVersion value() {
            return sourceVersion;
        }
           
        public boolean equals(Object o) {
            if (o instanceof SupportedSourceVersion) {
                SupportedSourceVersion ssv = (SupportedSourceVersion) o;
                return ssv.value() == sourceVersion;
            }
            return false;
        }

        public int hashCode() {
            return (127 * &quot;value&quot;.hashCode()) ^ sourceVersion.hashCode();
        }
    }

    public static void main(String... args) {
        SupportedSourceVersion reflectSSV =
            AnnotationEqualityDemonstration.class.getAnnotation(SupportedSourceVersion.class);
        SupportedSourceVersion localSSV = 
            new MySupportedSourceVersion(reflectSSV.value());

        System.out.println(&quot;reflectSSV == localSSV is &quot; +
                           (reflectSSV == localSSV));

        System.out.println(&quot;reflectSSV.equals(localSSV) is &quot; +
                           reflectSSV.equals(localSSV));

        System.out.println(&quot;localSSV.equals(reflectSSV) is &quot; +
                           localSSV.equals(reflectSSV));

        System.out.println(&quot;reflectSSV.getClass()equals(localSSV.getClass()) is &quot; +
                           reflectSSV.getClass().equals(localSSV.getClass()));

        System.out.println(&quot;\nreflectSSV.hashCode() is &quot; +
                           reflectSSV.hashCode());

        System.out.println(&quot;localSSV.hashCode()   is &quot; +
                           localSSV.hashCode());
    }
}

&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;

when run outputs:

&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
reflectSSV == localSSV is false
reflectSSV.equals(localSSV) is true
localSSV.equals(reflectSSV) is true
reflectSSV.getClass()equals(localSSV.getClass()) is false

reflectSSV.hashCode() is 1867635603
localSSV.hashCode()   is 1867635603
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;

The second kind of equality definition is specified for the language modeling interfaces in the &lt;code&gt;javax.lang.model.element&lt;/code&gt; package:

&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;
&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/javax/lang/model/element/Element.html#equals(java.lang.Object)&quot;&gt;javax.lang.model.element.Element.equals(Object)&lt;/a&gt;&lt;/code&gt;:&lt;br /&gt;

Note that the identity of an element involves implicit state not directly accessible from the element's methods, including state about the presence of unrelated types. Element objects created by different implementations of these interfaces should not be expected to be equal even if &quot;the same&quot; element is being modeled; this is analogous to the inequality of &lt;code&gt;Class&lt;/code&gt; objects for the same class file loaded through different class loaders. 

&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;

Inside &lt;code&gt;javac&lt;/code&gt;, instance control is used for the implementation classes for &lt;code&gt;javax.lang.model.element.Element&lt;/code&gt; subtypes. This allows the default pointer equality to be used and allows the hashing algorithm to not be specified.  Just as &lt;a href=&quot;http://en.wikiquote.org/wiki/Heraclitus&quot;&gt;you can't step in the same river twice&lt;/a&gt;,  the identity of an &lt;code&gt;Element&lt;/code&gt; object is tied to the context in which it is created.  Operationally, one consequence of this context sensitivity is that Element objects modeling &quot;the same&quot; type produced during different rounds of annotation processing will &lt;em&gt;not be equal&lt;/em&gt; even if there are equivalent methods, fields, constructors, etc. in both types in both rounds.

&lt;/p&gt;

&lt;p&gt;

When independent implementations of an interface and &lt;em&gt;not&lt;/em&gt; required to be equal to one another, the &lt;code&gt;hashCode&lt;/code&gt; algorithm does &lt;em&gt;not&lt;/em&gt; need to be specified, providing the implementer more flexibility.  This second style of specification allows disjoint islands of implementations to be defined.  

&lt;/p&gt;

&lt;p&gt;

Which style of specification is more appropriate depends on how the interface type is intended to be used.  Defining interoperable implementation is more difficult and limits the ability of the interface to be retrofitted onto existing types.  For example, while the Element interface and other interfaces from &lt;a href=&quot;http://jcp.org/en/jsr/detail?id=269&quot;&gt;JSR 269&lt;/a&gt; were successfully implemented by classes in both &lt;code&gt;javac&lt;/code&gt; and Eclipse, it would be impractical to expect Element objects from those disparate implementations to compare as equal.

&lt;a href=&quot;http://blogs.sun.com/darcy/entry/enums_and_mixins&quot; title=&quot;Mixing-in an Enum&quot;&gt;Mixin interfaces&lt;/a&gt;, like &lt;code&gt;CharSequence&lt;/code&gt; and &lt;code&gt;Closeable&lt;/code&gt;, should be cautious in defining equals behavior if the interface is intended to be widely implemented.  In some cases, a mixin interface can finesse this issue by being limited to an existing type hierarchy with already defined &lt;code&gt;equals&lt;/code&gt; and &lt;code&gt;hashCode&lt;/code&gt; polices.  For example, the &lt;code&gt;Parameterizable&lt;/code&gt; and &lt;code&gt;QualifiedNameable&lt;/code&gt; interfaces added to the &lt;code&gt;javax.lang.model.element&lt;/code&gt; package in JDK 7 
(&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6460529&quot; title=&quot;Provide mixin interfaces for getQualifiedName and getTypeParameters&quot;&gt;6460529&lt;/a&gt;) 
are extensions to &lt;code&gt;javax.lang.model.Element&lt;/code&gt; and therefore get to reuse the existing policies quoted above.

&lt;/p&gt;</description>
	<pubDate>Wed, 24 Feb 2010 17:00:00 +0000</pubDate>
</item>
<item>
	<title>David Gilbert: Be The Change</title>
	<guid>http://www.jroller.com/dgilbert/entry/be_the_change</guid>
	<link>http://www.jroller.com/dgilbert/entry/be_the_change</link>
	<description>So, yesterday was the 10 year anniversary of the first release of &lt;a href=&quot;http://www.jfree.org/jfreechart/&quot;&gt;JFreeChart&lt;/a&gt;, and it slipped by without me noticing!  I knew it was coming up, and even checked the exact date a few weeks back, but then on the day I had so much else to do.  Life is like that at the moment.  Anyway, tonight as I walked home from work I decided a small celebration was in order, so I bought a bottle of &lt;a href=&quot;http://www.marcfinewines.com/profile-New_Zealand-47.php&quot;&gt;New Zealand sunshine&lt;/a&gt; and...cheers!  Here's to 10 years, 50+ releases, 984+ bugs, 61,525 forum posts, 1.3 million downloads, and hundreds of millions of charts generated.  
&lt;br /&gt;&lt;br /&gt;</description>
	<pubDate>Tue, 23 Feb 2010 21:43:28 +0000</pubDate>
</item>
<item>
	<title>Roman Kennke: Beatles review: Please Please Me</title>
	<guid>http://rkennke.wordpress.com/?p=294</guid>
	<link>http://rkennke.wordpress.com/2010/02/22/beatles-review-please-please-me/</link>
	<description>&lt;p&gt;At the end of last year, EMI/Apple re-released the whole Beatles catalogue as a series (or box sets) of remastered CDs. The Beatles were more or less my first encounter with pop music when I was 8 or so, my first self-bought CD at the age of 12 was a Beatles CD and of course, I had to go out and buy these excellent remasters, I got both the mono and stereo editions. I had many weeks now listening these CDs and re-discovering some of the stuff was quite fun, and I want to share my impressions in a short series of short reviews intermingled with some personal anecdotes. Let&amp;#8217;s do it in order of the release of the original LPs and start with &amp;#8216;&lt;a href=&quot;http://www.lastfm.de/music/The+Beatles/Please+Please+Me&quot;&gt;Please Please Me&lt;/a&gt;&amp;#8216;.&lt;/p&gt;
&lt;p&gt;I think this is quite a good career starter. Innocent, powerful, inspired, raw, rocking. It has most of the ingredients of their later Beatlemania success albums, i.e. love songs (P.S. I love you and most others), rockers (I Saw Her Standing There,&amp;#8230;), some cover versions , a slightly more exotic song (A Taste of Honey), some Ringo (Boys), some George (Do You Want To Know a Secret), a weird sense of humor (the Beatles covering a girl group talking about &amp;#8216;Boys&amp;#8217;). I really always enjoy this album. It was recorded in one day, and with John having a sore throat, and it shows &amp;#8211; positively. From the first through the last song you can literally feel the energy of those 4 relatively unknown guys, and sense that the Beatlemania is already about to start. It is what the Beatles were at this point: a hard working live band. Interesting the last song: a kamikaze version of Twist and Shout, with John shredding his vocal chords. Hilarious. It could have been a total fail (with no second chance to record it), but instead it became music history. The stereo version is mostly relevant for historical reasons, the sound beeing a bit thin and the mixes having several glitches which were corrected in the mono mixes. These mono mixes on the other hand are just great and solid rocking. All in all the album always makes for a happy-go-lucky listen on sunny afternoons, even if it is not one of the totally essential ones. Also interesting to note is also the album cover: it shows the four guys on the stairs in the EMI building. Several years later they did the exact same scene again, now with long hair, for the planned last album (Get Back, which should become Let it Be). Both pictures would later be used for the red and blue best of double albums.&lt;/p&gt;
&lt;p&gt;Next one up will be &lt;a href=&quot;http://rkennke.wordpress.com/2010/02/24/beatles-review-with-the-beatles/&quot;&gt;With The Beatles&lt;/a&gt;. Stay tuned. Please tell me what you think about the album in the comments.&lt;/p&gt;
&lt;br /&gt;  &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gocomments/rkennke.wordpress.com/294/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/comments/rkennke.wordpress.com/294/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godelicious/rkennke.wordpress.com/294/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/delicious/rkennke.wordpress.com/294/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/gostumble/rkennke.wordpress.com/294/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/stumble/rkennke.wordpress.com/294/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/godigg/rkennke.wordpress.com/294/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/digg/rkennke.wordpress.com/294/&quot; /&gt;&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;http://feeds.wordpress.com/1.0/goreddit/rkennke.wordpress.com/294/&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://feeds.wordpress.com/1.0/reddit/rkennke.wordpress.com/294/&quot; /&gt;&lt;/a&gt; &lt;img alt=&quot;&quot; border=&quot;0&quot; src=&quot;http://stats.wordpress.com/b.gif?host=rkennke.wordpress.com&amp;blog=9951657&amp;post=294&amp;subd=rkennke&amp;ref=&amp;feed=1&quot; /&gt;rkennke</description>
	<pubDate>Mon, 22 Feb 2010 19:28:04 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: Everything Older is Newer Once Again</title>
	<guid>http://blogs.sun.com/darcy/entry/everything_older_is_newer_once</guid>
	<link>http://blogs.sun.com/darcy/entry/everything_older_is_newer_once</link>
	<description>&lt;p&gt;

Catching up on writing about more numerical work from years past, the &lt;a href=&quot;http://www.ibm.com/developerworks/java/library/j-math2.html&quot; title=&quot;Java's new math, Part 2: Floating-point numbers&quot;&gt;second article&lt;/a&gt; in a two-part series finished last year discusses some low-level floating-point manipulations methods I added to the platform over the course of JDKs 5 and 6.

Previously, I published a 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/everything_old_is_new_again&quot; title=&quot;Everything Old is New Again&quot;&gt;blog entry reacting to&lt;/a&gt; the 
&lt;a href=&quot;http://www.ibm.com/developerworks/java/library/j-math1/index.html&quot; title=&quot;Java's new math, Part 1: Real numbers&quot;&gt;first part&lt;/a&gt; of the series.

&lt;/p&gt;

&lt;p&gt;

JDK 6 enjoyed several numerics-related library changes.  Constants for &lt;code&gt;MIN_NORMAL&lt;/code&gt;, &lt;code&gt;MIN_EXPONENT&lt;/code&gt;, and &lt;code&gt;MAX_EXPONENT&lt;/code&gt; were added to the &lt;code&gt;Float&lt;/code&gt; and &lt;code&gt;Double&lt;/code&gt; classes.  I also added to the &lt;code&gt;Math&lt;/code&gt; and &lt;code&gt;StrictMath&lt;/code&gt; classes the following methods for low-level manipulation of floating-point values:

&lt;/p&gt;


&lt;ul&gt;

&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Math.html#copySign(double,%20double)&quot;&gt;
public static double copySign(double magnitude, double sign)&lt;/a&gt;&lt;/code&gt;

&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Math.html#getExponent(double)&quot;&gt;public static int getExponent(double d)&lt;/a&gt;&lt;/code&gt;

&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Math.html#nextAfter(double,%20double)&quot;&gt;public static double nextAfter(double start, double direction)&lt;/a&gt;&lt;/code&gt;

&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Math.html#nextUp(double)&quot;&gt;public static double nextUp(double d)&lt;/a&gt;&lt;/code&gt;

&lt;li&gt;&lt;code&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Math.html#scalb(double,%20int)&quot;&gt;public static double scalb(double d, int scaleFactor)&lt;/a&gt;&lt;/code&gt;

&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;

There are also overloaded methods for &lt;code&gt;float&lt;/code&gt; arguments.   

In terms of the &lt;a href=&quot;http://en.wikipedia.org/wiki/IEEE_754-1985&quot;&gt;IEEE 754 standard from 1985&lt;/a&gt;, the methods above provide the core functionality of the &lt;i&gt;recommended functions&lt;/i&gt;.  In terms of the &lt;a href=&quot;http://en.wikipedia.org/wiki/IEEE_754-2008&quot;&gt;2008 revision to IEEE 754&lt;/a&gt;, analogous functions are integrated throughout different sections of the document.

&lt;/p&gt;

&lt;p&gt;

While a student at Berkeley, I wrote a 
&lt;a href=&quot;http://www.jddarcy.org/Research/ieeerecd.pdf&quot;&gt;tech report&lt;/a&gt; on algorithms I developed for an earlier implementation of these methods, an implementation written many years ago when I was a summer intern at  Sun.

The &lt;a href=&quot;http://hg.openjdk.java.net/jdk7/tl/jdk/file/84792500750c/src/share/classes/sun/misc/FpUtils.java&quot; title=&quot;sun.misc.FpUtils as of Feb. 20, 2010&quot;&gt;implementation of the recommended functions in the JDK&lt;a&gt; is a refinement of the earlier work, a refinement that simplified code, added &lt;a href=&quot;http://hg.openjdk.java.net/jdk7/tl/jdk/file/84792500750c/test/java/lang/Math/IeeeRecommendedTests.java&quot; title=&quot;IeeeRecommendedTests.java regression test as of Feb. 20, 2010&quot;&gt;extensive&lt;/a&gt; and 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/test_where_the_failures_are&quot; title=&quot;Test where the failures are likely to be&quot;&gt;effective&lt;/a&gt; unit tests, and sported better performance in some cases.

In part the simplifications came from &lt;em&gt;not&lt;/em&gt; attempting to accommodate IEEE 754 features not natively supported in the Java platform, in particular rounding modes and sticky flags.

&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;

The primary purpose of these methods is to assist in in the development of math libraries in Java, such as the recent 
&lt;a href=&quot;http://hg.openjdk.java.net/jdk7/jdk7/jdk/rev/ad1e30930c6c&quot;&gt;pure Java implementation of floor and ceil&lt;/a&gt;
(&lt;a href=&quot;http://bugs.sun.com/view_bug.do?bug_id=6908131&quot; title=&quot;Pure Java implementations of StrictMath.floor(double) &amp; StrictMath.ceil(double)&quot;&gt;6908131&lt;/a&gt;).  

This expected use-case drove certain API differences with the functions sketched by IEEE 754.  For example, the &lt;code&gt;getExponent&lt;/code&gt; method simply returns the unbiased value stored in the exponent field of a floating-point value rather than doing additional processing, such as computing the exponent needed to normalized a subnormal number, additional processing called for in some flavors of the 754 &lt;code&gt;logb&lt;/code&gt; operation.  Such additional functionality can actually slow down math libraries since libraries may not benefit from the additional filtering and may actually have to undo it.

&lt;/p&gt;

&lt;p&gt;

The &lt;code&gt;Math&lt;/code&gt; and &lt;code&gt;StrictMath&lt;/code&gt; specifications of &lt;code&gt;copySign&lt;/code&gt; have a small difference: the 
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/StrictMath.html#copySign(double,%20double)&quot; title=&quot;java.lang.StrictMath.copySign&quot;&gt;&lt;code&gt;StrictMath&lt;/code&gt; version&lt;/a&gt; always treats NaNs as having a positive sign (a sign bit of zero) while the 
&lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/Math.html#copySign(double,%20double)&quot; title=&quot;java.lang.Math.copySign&quot;&gt;&lt;code&gt;Math&lt;/code&gt; version&lt;/a&gt; does not impose this requirement.

The IEEE standard does not ascribe a meaning to the sign bit of a NaN and difference processors have different conventions NaN representations and how they propagate.  However, if the source argument is not a NaN, the two &lt;code&gt;copySign&lt;/code&gt; methods will produce equivalent results.

Therefore, even if being used in a library where the results need to be completely predictable, the faster &lt;code&gt;Math&lt;/code&gt; version of &lt;code&gt;copySign&lt;/code&gt; can be used as long as the source argument is known to be numerical.

&lt;/p&gt;

&lt;p&gt;

The recommended functions can also be used to solve a little floating-point puzzle: generating the interesting limit values of a floating-point format just starting with constants for &lt;code&gt;0.0&lt;/code&gt; and &lt;code&gt;1.0&lt;/code&gt; in that format:

&lt;/p&gt;

&lt;ul&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;NaN&lt;/code&gt; is &lt;code&gt;0.0/0.0&lt;/code&gt;.
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;POSITIVE_INFINITY&lt;/code&gt; is &lt;code&gt;1.0/0.0&lt;/code&gt;.
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;MAX_VALUE&lt;/code&gt; is &lt;code&gt;nextAfter(POSITIVE_INFINITY, 0.0)&lt;/code&gt;.
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;MIN_VALUE&lt;/code&gt; is &lt;code&gt;nextUp(0.0)&lt;/code&gt;.
&lt;/p&gt;

&lt;li&gt;&lt;p&gt;&lt;code&gt;MIN_NORMAL&lt;/code&gt; is &lt;code&gt;MIN_VALUE/(nextUp(1.0)-1.0)&lt;/code&gt;.
&lt;/p&gt;

&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;</description>
	<pubDate>Sun, 21 Feb 2010 05:41:48 +0000</pubDate>
</item>
<item>
	<title>Jeroen Frijters: 0.42 Update 1 RC 1</title>
	<guid>http://weblog.ikvm.net/PermaLink.aspx?guid=ac55cc6d-8a72-469b-98c6-84d19ec309b8</guid>
	<link>http://weblog.ikvm.net/PermaLink.aspx?guid=ac55cc6d-8a72-469b-98c6-84d19ec309b8</link>
	<description>&lt;p&gt;
      I fixed a major bug in the automagic .NET serialization support.
   &lt;/p&gt;
        &lt;p&gt;
      Changes:
   &lt;/p&gt;
        &lt;ul&gt;
          &lt;li&gt;
         Updated version to 0.42.0.5.&lt;/li&gt;
          &lt;li&gt;
         Fix for bug #&lt;a href=&quot;https://sourceforge.net/tracker/?func=detail&amp;atid=525264&amp;aid=2946842&amp;group_id=69637&quot;&gt;2946842&lt;/a&gt;.&lt;/li&gt;
        &lt;/ul&gt;
        &lt;p&gt;
      Binaries available here: &lt;a href=&quot;http://www.frijters.net/ikvmbin-0.42.0.5.zip&quot;&gt;ikvmbin-0.42.0.5.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
      Sources: &lt;a href=&quot;http://www.frijters.net/ikvm-0.42.0.5.zip&quot;&gt;ikvm-0.42.0.5.zip&lt;/a&gt;, &lt;a href=&quot;http://www.frijters.net/openjdk6-b16-stripped.zip&quot;&gt;openjdk6-b16-stripped.zip&lt;/a&gt;&lt;/p&gt;
        &lt;img width=&quot;0&quot; height=&quot;0&quot; src=&quot;http://weblog.ikvm.net/aggbug.ashx?id=ac55cc6d-8a72-469b-98c6-84d19ec309b8&quot; /&gt;</description>
	<pubDate>Fri, 19 Feb 2010 08:40:08 +0000</pubDate>
</item>
<item>
	<title>Andrew Hughes: OpenJDK6 b18 Released and in IcedTea6!</title>
	<guid>http://blog.fuseyism.com/?p=94</guid>
	<link>http://blog.fuseyism.com/index.php/2010/02/18/openjdk6-b18-released-and-in-icedtea6/</link>
	<description>&lt;p&gt;Joe Darcy released &lt;a href=&quot;http://blogs.sun.com/darcy/entry/openjdk_6_b18_source_bundle&quot;&gt;OpenJDK6 b18&lt;/a&gt; yesterday evening and this is now integrated with the &lt;a href=&quot;http://icedtea.classpath.org/hg/icedtea6&quot;&gt;latest IcedTea6 from Mercurial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To build:&lt;/p&gt;
&lt;pre&gt;
$ hg clone http://icedtea.classpath.org/hg/icedtea6
$ mkdir icedtea6-build
$ cd icedtea6-build
$ ../icedtea6/configure
$ make
&lt;/pre&gt;
&lt;p&gt;Then grab a beverage of your choice and wait a while&amp;#8230; I recommend adding &lt;code&gt;--with-parallel-jobs&lt;/code&gt; to the configure invocation if you have a multi-core machine.&lt;/p&gt;
&lt;p&gt;Once built, you will have a build of OpenJDK6 which can use the Nimbus Look and Feel as explained in &lt;a href=&quot;http://blog.fuseyism.com/index.php/2009/04/09/nimbus-arrives/&quot;&gt;my previous blog&lt;/a&gt;&lt;/p&gt;</description>
	<pubDate>Thu, 18 Feb 2010 18:23:52 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: OpenJDK 6: b18 regression test results</title>
	<guid>http://blogs.sun.com/darcy/entry/openjdk_6_b18_regression_tests</guid>
	<link>http://blogs.sun.com/darcy/entry/openjdk_6_b18_regression_tests</link>
	<description>&lt;p&gt;

Running with the usual &lt;tt&gt;jtreg&lt;/tt&gt; flags, &lt;tt&gt;-a -ignore:quiet&lt;/tt&gt; in all repositories and adding &lt;tt&gt;-s&lt;/tt&gt; for &lt;tt&gt;langtools&lt;/tt&gt;, the basic regression test results on Linux for
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/openjdk_6_b18_source_bundle&quot;&gt;OpenJDK 6 build 18&lt;/a&gt; are:

&lt;/p&gt;


&lt;ul&gt;

&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://blogs.sun.com/darcy/resource/OpenJDK_6/b18-hotspot-linux-summary.txt&quot;&gt;HotSpot&lt;/a&gt;, 24 tests passed.
&lt;/p&gt;


&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://blogs.sun.com/darcy/resource/OpenJDK_6/b18-langtools-linux-summary.txt&quot;&gt;Langtools&lt;/a&gt;, 1,355 tests passed.
&lt;/p&gt;


&lt;li&gt;&lt;p&gt;&lt;a href=&quot;http://blogs.sun.com/darcy/resource/OpenJDK_6/b18-jdk-linux-summary.txt&quot;&gt;JDK&lt;/a&gt;, 3,148 tests pass, 19 fail, and 2 have errors.
&lt;/p&gt;

&lt;/li&gt;&lt;/li&gt;&lt;/li&gt;&lt;/ul&gt;


&lt;p&gt;


All the HotSpot tests continue to pass:

&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre&gt;
0: b17-hotspot/summary.txt  pass: 24
1: b18-hotspot/summary.txt  pass: 24

No differences
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;

In &lt;tt&gt;langtools&lt;/tt&gt; all the tests continue to pass and one test was added:

&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre&gt;
0: b17-langtools/summary.txt  pass: 1,354
1: b18-langtools/summary.txt  pass: 1,355

0      1      Test
---    pass   tools/javac/T6855236.java

1 differences
&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;

And in &lt;tt&gt;jdk&lt;/tt&gt;, a few dozen new tests were added in b18 and the existing tests have generally consistent results, with a number of long-standing test failures corrected by Pavel Tisnovsky.

The test run below was executed outside of Sun's and Oracle's wide-area network using the following contents for the testing network configuration file:

&lt;blockquote&gt;&lt;pre&gt;
host=icedtea.classpath.org
refusing_host=ns1.gnu.org
far_host=developer.classpath.org
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;

The file location to use for the networking configuration can be set by passing a &lt;code&gt;-e JTREG_TESTENV=&lt;i&gt;Path to file&lt;/i&gt;&lt;/code&gt; option to &lt;code&gt;jtreg&lt;/code&gt;.

&lt;/p&gt;

&lt;/p&gt;

&lt;blockquote&gt;
&lt;pre&gt;
0: b17-jdk/summary.txt  pass: 3,118; fail: 26
1: b18-jdk/summary.txt  pass: 3,148; fail: 19; error: 2

0      1      Test
---    pass   com/sun/java/swing/plaf/nimbus/Test6741426.java
---    pass   com/sun/java/swing/plaf/nimbus/Test6849805.java
---    pass   com/sun/jdi/BreakpointWithFullGC.sh
---    pass   com/sun/jdi/ResumeOneThreadTest.java
---    pass   com/sun/jdi/SimulResumerTest.java
---    pass   demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java
fail   pass   java/awt/Frame/DynamicLayout/DynamicLayout.java
fail   pass   java/awt/Frame/MaximizedToIconified/MaximizedToIconified.java
fail   pass   java/awt/Frame/ShownOffScreenOnWin98/ShownOffScreenOnWin98Test.java
fail   pass   java/awt/Frame/UnfocusableMaximizedFrameResizablity/UnfocusableMaximizedFrameResizablity.java
---    pass   java/awt/GraphicsDevice/CloneConfigsTest.java
fail   pass   java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java
fail   pass   java/awt/Insets/CombinedTestApp1.java
fail   pass   java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.html
fail   pass   java/awt/KeyboardFocusmanager/TypeAhead/MenuItemActivatedTest/MenuItemActivatedTest.html
fail   pass   java/awt/KeyboardFocusmanager/TypeAhead/SubMenuShowTest/SubMenuShowTest.html
fail   pass   java/awt/KeyboardFocusmanager/TypeAhead/TestDialogTypeAhead.html
pass   fail   java/awt/Multiscreen/LocationRelativeToTest/LocationRelativeToTest.java
fail   pass   java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.html
fail   pass   java/awt/Toolkit/ScreenInsetsTest/ScreenInsetsTest.java
pass   ---    java/awt/Window/AlwaysOnTop/AlwaysOnTopEvenOfWindow.java
pass   fail   java/awt/Window/GrabSequence/GrabSequence.java
fail   pass   java/awt/grab/EmbeddedFrameTest1/EmbeddedFrameTest1.java
pass   fail   java/awt/print/PrinterJob/ExceptionTest.java
---    pass   java/lang/ClassLoader/UninitializedParent.java
pass   fail   java/net/ipv6tests/TcpTest.java
pass   fail   java/nio/channels/SocketChannel/AdaptSocket.java
pass   fail   java/nio/channels/SocketChannel/LocalAddress.java
pass   fail   java/nio/channels/SocketChannel/Shutdown.java
pass   fail   java/rmi/transport/pinLastArguments/PinLastArguments.java
---    pass   java/util/TimeZone/OldIDMappingTest.sh
---    pass   java/util/TimeZone/TimeZoneDatePermissionCheck.sh
---    pass   javax/swing/JButton/6604281/bug6604281.java
fail   pass   javax/swing/JTextArea/Test6593649.java
---    pass   javax/swing/Security/6657138/ComponentTest.java
---    pass   javax/swing/Security/6657138/bug6657138.java
---    pass   javax/swing/ToolTipManager/Test6657026.java
---    pass   javax/swing/UIManager/Test6657026.java
---    pass   javax/swing/plaf/basic/BasicSplitPaneUI/Test6657026.java
---    pass   javax/swing/plaf/metal/MetalBorders/Test6657026.java
---    pass   javax/swing/plaf/metal/MetalBumps/Test6657026.java
---    pass   javax/swing/plaf/metal/MetalInternalFrameUI/Test6657026.java
---    pass   javax/swing/plaf/metal/MetalSliderUI/Test6657026.java
pass   error  sun/java2d/OpenGL/GradientPaints.java
pass   fail   sun/rmi/transport/proxy/EagerHttpFallback.java
---    pass   sun/security/provider/certpath/DisabledAlgorithms/CPBuilder.java
---    pass   sun/security/provider/certpath/DisabledAlgorithms/CPValidatorEndEntity.java
---    pass   sun/security/provider/certpath/DisabledAlgorithms/CPValidatorIntermediate.java
---    pass   sun/security/provider/certpath/DisabledAlgorithms/CPValidatorTrustAnchor.java
pass   error  sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java
---    pass   sun/security/tools/jarsigner/emptymanifest.sh
---    pass   sun/security/util/DerValue/BadValue.java
fail   pass   sun/tools/jhat/HatHeapDump1Test.java
fail   pass   sun/tools/native2ascii/NativeErrors.java

54 differences
&lt;/pre&gt;
&lt;/blockquote&gt;</description>
	<pubDate>Wed, 17 Feb 2010 17:35:00 +0000</pubDate>
</item>
<item>
	<title>Joe Darcy: OpenJDK 6: b18 Source Bundle Published</title>
	<guid>http://blogs.sun.com/darcy/entry/openjdk_6_b18_source_bundle</guid>
	<link>http://blogs.sun.com/darcy/entry/openjdk_6_b18_source_bundle</link>
	<description>&lt;p&gt;

On February 16, 2010 the
&lt;a href=&quot;http://download.java.net/openjdk/jdk6/promoted/b18/openjdk-6-src-b18-16_feb_2010.tar.gz&quot;&gt;source bundle&lt;/a&gt; for OpenJDK 6 b18 was published.

&lt;/p&gt;

&lt;p&gt;

Major changes in this build include the latest round of security fixes and, courtesy of Andrew John Hughes, a backport of the Nimbus look and feel from JDK 7.  In addition, a 
&lt;a href=&quot;http://blogs.sun.com/darcy/entry/jdk_7_new_component_delivered&quot; title=&quot;JDK 7: New Component Delivery Model Delivered&quot;&gt;new delivery model&lt;/a&gt; is being used for the &lt;code&gt;jaxp&lt;/code&gt; and &lt;code&gt;jax-ws&lt;/code&gt; components.

&lt;/p&gt;

&lt;p&gt;

A detailed list of all the changes is &lt;a href=&quot;http://blogs.sun.com/darcy/resource/OpenJDK_6/openjdk6-b18-changes-summary.html&quot;&gt;also available&lt;/a&gt;.

&lt;/p&gt;</description>
	<pubDate>Wed, 17 Feb 2010 17:30:00 +0000</pubDate>
</item>
<item>
	<title>Mario Torre: Heavy Rain</title>
	<guid>http://www.jroller.com/neugens/entry/heavy_rain</guid>
	<link>http://www.jroller.com/neugens/entry/heavy_rain</link>
	<description>&lt;p&gt;There&amp;#8216;s a lot of hype around &lt;a href=&quot;http://en.wikipedia.org/wiki/Heavy_Rain&quot;&gt;this title&lt;/a&gt;. I gave a look at the trailers and I had the feeling that the game play was so similar to very old games (1983!) such as Dragon&amp;#8216;s Lair or Space Quest.&lt;/p&gt;

	&lt;p&gt;Today, I finally played the demo and I still have constrasting feelings&amp;#8230; Is it cool? Yeah&amp;#8230; I think it is, really: it&amp;#8216;s like playing a film, full of dark mood, beautiful scenes and colours, and a really intriguing story.&lt;/p&gt;

	&lt;p&gt;The demo shows some funny behaviour, for example, when not triggering a cut scene (that is, 90% of the time &lt;strong&gt;you are&lt;/strong&gt; in a cut scene), the non playing characters (NPEs) look a bit dumb. In fact, you have the feeling that everything is a bit fake, because the interaction takes place only when is supposed to, and you find yourself wandering around the area without knowing what to do when you have no more options left, with the NPCs staring a wall with idiotic espression :)&lt;/p&gt;

	&lt;p&gt;There is a nice system that tries to address this issue and adds even more of a nice movie mood to the game: you can listen to your character&amp;#8216;s thoughts, and they act like an offscreen narrator, very cool I have to say.&lt;/p&gt;

	&lt;p&gt;The game play is almost non existent, though, you press one button or two when some HUDs pops up and inevitably mess with the Sixaxis controller&amp;#8230; On the other hand, is really beautiful to watch. I suggest to wait a full review on Gamespot, but the game is cool so far.&lt;/p&gt;

	&lt;p&gt;I confirm that is the same kind of game as Dragon&amp;#8216;s Lair and Space Ace, be warned if you don&amp;#8216;t like this kind of stuff.&lt;/p&gt;

	&lt;p&gt;&lt;center&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/center&gt;&lt;/p&gt;

	&lt;p&gt;&lt;center&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/center&gt;&lt;/p&gt;

	&lt;p&gt;&lt;center&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/center&gt;&lt;/p&gt;</description>
	<pubDate>Mon, 15 Feb 2010 21:37:25 +0000</pubDate>
</item>

</channel>
</rss>
