• Post Reply Bookmark Topic Watch Topic
  • New Topic

Integer.equals() failing in java 1.3?  RSS feed

 
Michael Chermside
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Chermside
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!