Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:11:34+00:00 2026-06-13T07:11:34+00:00

I got hit with the (apparently infamous) IllegalArgumentException using Collections.sort() in Java7 Thanks to

  • 0

I got hit with the (apparently infamous) IllegalArgumentException using Collections.sort() in Java7
Thanks to SO I understand the cause, which is basically (cough) poor code.
The thing is, I cannot reproduce the Exception myself. I did some jdk source code digging, and located which class is throwing that exception. The idea is to create the according Test Case.

Here is the code, by the way
< pride level=”0″ >

@Override
public int compareTo( Symbol other) {
    if( this.lastUse == 0) {
        if( other.lastUse != 0) return (int)( -DateMicros.ONE_DAY);
    } else if( other.lastUse == 0) {
        return ( int)DateMicros.ONE_DAY;
    }
    return ( int)( this.lastUse - other.lastUse);
}

< /pride >
On top of this, “lastUse” gets assigned timestamps in microseconds and milliseconds (yes mixed) which gives a superb int overflow spillage

The actual question is:
What Values Would make This Code Crash? to get a proper test case down the road.

Update with stack trace:

at java.util.ComparableTimSort.mergeHi(Unknown Source)
at java.util.ComparableTimSort.mergeAt(Unknown Source)
at java.util.ComparableTimSort.mergeCollapse(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:11:35+00:00Added an answer on June 13, 2026 at 7:11 am

    Hard to tell without looking at the stacktrace itself.

    But the docs mentions that the method itself can throw the exception.

    (optional) if the implementation detects that the natural ordering of the list elements is found to violate the Comparable contract

    Update

    It looks like because your object does not fulfull the Comparable consistency requirement:

    The natural ordering for a class C is said to be consistent with equals if and only if e1.compareTo(e2) == 0 has the same boolean value as e1.equals(e2) for every e1 and e2 of class C. Note that null is not an instance of any class, and e.compareTo(null) should throw a NullPointerException even though e.equals(null) returns false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got help with correct calculation the other day but I've hit a block
I've hit an annoying problem in LaTeX. I've got a tex file of about
I got all excited with the leaked froyo update.zip that hit the net a
I have some problem with JSON parsing. When I hit URL, I've got JSON
I got a JQuery/CSS tabcontrol, which currently handle 4 tabs, containing gridviews. I'd like
I've got the following list List<int> deletedRecords = new List<int>(); When I hit the
I admin a couple pages on FB and we recently got hit by a
I want to restart the vaadin application whenever I got a hit to the
I've got the following user data for my site: 1) Hit IP, location 2)
I've got a problem with backspaces in Vim. If I hit backspace, the last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.