JDK-6370431 : (coll) PriorityQueue.fixUp() use >> instead of >>>
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:collections
  • Affected Version: 6
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-01-10
  • Updated: 2012-10-08
  • Resolved: 2006-03-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b78Fixed
Related Reports
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b61)
Java HotSpot(TM) Client VM (build 1.6.0-rc-b61, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
In the class PriorityQueue, the method fixUp contains
twice a similary code. (one with a comparator and
one with comparable)

in the comparable version, to obtain the parent,
the line is 'int j = k >> 1;'
in the comparator version,
the line is 'int j = k >>> 1;'

the comparable version use a >> instead of a >>>,
so the sign bit is not shift as it does.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
i have read the source, so i don't have any test.


REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Use a comparator instead of a comparable.

Comments
EVALUATION Doug Lea is providing a reliability/performance facelift of PriorityQueue in 6394004: (coll) Thread-safety and Performance improvements to PriorityQueue so this tiny issue will vanish.
06-03-2006

EVALUATION Since k is always positive, >> and >>> are equivalent, so there is no actual bug here. Nevertheless, the use of two different operators here is confusing; they should be consistent, as suggested. >> is better, since >>> suggests k might be negative.
13-01-2006