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

  • Home
  • SEARCH
  • 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 8874745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:47:59+00:00 2026-06-14T18:47:59+00:00

It seems that not all .equals() methods are created equal. I’ve been testing backwards

  • 0

It seems that not all .equals() methods are created equal.

I’ve been testing backwards compatibility on an android app and noticed something peculiar. When I tested my app under Froyo (2.2), RectF.equals() fails when used to compare two identical objects. Rect.equals() works as expected on all versions, but RectF seems to have overhauled in between Froyo and Jelly Bean. Stepping through the source code, it seems that RectF never overrode .equals and just used the Object implementation. Not so with Rect.equals, however.

    Rect r1 = new Rect(0,0,1,1);
    Rect r2 = new Rect(r1);

    RectF rf1 = new RectF(0,0,1,1);
    RectF rf2 = new RectF(rf1);

    if (r1.equals(r2))
        Log.d(Build.VERSION.RELEASE,"r1 and r2 are equal");
    else
        Log.d(Build.VERSION.RELEASE,"r1 and r2 are NOT equal");

    if (rf1.equals(rf2))
        Log.d(Build.VERSION.RELEASE,"rf1 and rf2 are equal");
    else
        Log.d(Build.VERSION.RELEASE,"rf1 and rf2 are NOT equal");

Looking at the code above, one would expect both .equals() to return true. Not so. the Rect comparison always returns true, while the RectF comparison returns true on my Nexus 7 and false on every other device. Arrgh!

It took me a while to find this problem as I’ve used Rect objects extensively and never had a problem. I never considered that RectF would be so inconsistent.

My question is: How can I easily find reference to changes to Android source objects between versions? The API Reference makes mention of new methods and deprecation but doesn’t mention when the behaviour of methods is dramatically altered. I also scanned the bug list on code.google.com but found nothing about it. Is their another online resource that I can use when I’m suspicious of an inconsistency? I don’t want to have to traipse through the android source every time I have a problem, when I have a hard enough time dealing with my own bugs/inconsistencies. For instance, is there an easy way for me to find the entire change history for RectF?

thanks,

  • 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-14T18:48:01+00:00Added an answer on June 14, 2026 at 6:48 pm

    The RectF class had a typo in its equals() method. The bug was:

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
    
        // RectF r = (Rect) o; <=== bug!
        RectF r = (RectF) o;
        return left == r.left && top == r.top && right == r.right && bottom == r.bottom;
    }
    

    If you go to the GitHub source for RectF and click on “History”, you’ll find an entry on March 9, 2012 titled “Fix a typo in RectF.equals”. Click on that and you can see the change.

    I didn’t bother to track down exactly which release of Android first contains this fix. But since it’s fairly recent, you should expect that for some time to come, most devices will have the bug.

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

Sidebar

Related Questions

It seems that calling a P-Invoke while the App is not completed loaded make
It seems that it is not advisable to use <meta http-equiv=REFRESH CONTENT=3;url=url> for redirects
I have a problem that I have not faced before: It seems that the
I am using ZUUIRevealController in my project. It seems that memory is not freed
I have the following, which doesn't work, my validation seems that it's not triggered
it seems that Markdown.NET does not escape the following: <script> which is kind of
It seems that SQL Server does not accept numbers formatted using any particular locale.
It seems that Visual Basic can not reference sheets according to user-modified sheet names.
It seems that the WPF Rectangle shape does not have the Click event defined.
It seems that there is a guidance that a model should not expose its

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.