aspose file tools*
The moose likes Java in General and the fly likes Integer.equals() failing in java 1.3? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Integer.equals() failing in java 1.3?" Watch "Integer.equals() failing in java 1.3?" New topic
Author

Integer.equals() failing in java 1.3?

Michael Chermside
Greenhorn

Joined: Jul 22, 2003
Posts: 11
Has anybody ever seen anything like this? We're running a process (Websphere, actually, with an application in it) on java 1.3 hotspot (build 1.3.1_03-b03 to be specific). After the application has been up and running for a long time we start getting a peculiar error. One possible explanation for the error would be if the equals() method on Integer were failing (returning false for two Integers both containing 0). Has anyone ever heard of such a thing? It's a pretty ridiculous idea, but at the moment my other possible explanations are looking a bit ridiculous also, so I thought I'd ask.
-- Michael Chermside
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

It's not absolutely impossible, I suppose. The code for Integer.equals() is

So if you had two different instances of Integer, each one an instance of a version of the class loaded from two different class loaders, then this could return false regardless of the numeric values -- the instanceof would fail.
Normally, system classes should never be loaded by user classloaders. But app servers use lots of custom loaders, and a badly written or badly configured one might accidentally do such a thing, so if it's ever going to happen, it would be in an app server.


[Jess in Action][AskingGoodQuestions]
Michael Chermside
Greenhorn

Joined: Jul 22, 2003
Posts: 11
Ernest Friedman-Hill writes:
...So if you had two different instances of Integer, each one an instance of a version of the class loaded from two different class loaders...

Aha! Given what we are doing here, that explanation is not entirely implausible. Thanks! It may not be the answer, but at least it's a reasonable possibility that I can investigate.
 
wood burning stoves
 
subject: Integer.equals() failing in java 1.3?