Tools or VM agents to verify hashCode/equals/compareTo contracts

Kelly O'Hair kelly.ohair at workday.com
Thu Apr 4 09:37:30 PDT 2013


The get out of jail card is being used already, but we don't want to keep
using it. :^(

The issue is that the TimSort does this:
 throw new IllegalArgumentException("Comparison method violates its
general contract!");
with not a great deal of information to help identify the problem. The
sort just fails.
Given 100,000 objects or more, not often easy to diagnose at this point.
Hard problem.

I suppose catching the exception, and then doing an old sort and maybe some
analysis on the objects in the list or set being sorted,
but I was thinking maybe it could be done via an agent and not permanent
Java logic, somehow.
Like a debug agent that watches for unusual behaviors and does automatic
Digging into the details, or stats, or something more than a stack trace
to this
Throw statement. A benign agent of goodness, like a runtime findbugs. :^)

-kto


On 4/4/13 8:21 AM, "Tim Bell" <tim.bell at oracle.com> wrote:

>On 04/04/13 01:35, Alan Bateman wrote:
>> On The TimSort then I assume you know there is a system property to
>> use merge sort (this will of course hide the problem as before but
>> useful as a get-of-jail card if you need it).
>
>In that case, a debug or assert checking mode could do the sorting both
>ways and then compare the results...
>
>Tim
>
>
>



More information about the serviceability-dev mailing list