Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1240827

fp.bugs 3908 or() operation on BitSets has a significant bug.

XMLWordPrintable

    • 1.1
    • sparc
    • solaris_2.5
    • Not verified

      From: ###@###.### (Scott Hudson)
      This does not look like form output to me.


      // Bug report on java.util.BitSet.or()
      // from Scott Hudson, ###@###.###
      //
      // It appears that the or() operation on BitSets has a significant bug.
      // In particular, it does not seem to extend the size of the destination
      // set to incorporate all elements of the source set. This leads to
      // inconsistent behavior depending on whether where values fall wrt
      // the current internally allocates size of the destination set (not to
      // mention breaking various normal properties of sets).
      //
      // The program below demonstates the bug.
      //
       
      import java.util.BitSet;
       
      public class bitset_or_bug {
        
        public static void main(String argv[])
          {
            BitSet s1 = new BitSet(1);
            BitSet s2 = new BitSet(1);
            BitSet s3 = new BitSet(1);
       
            s1.set(30);
            s2.set(60);
            s3.set(90);
       
            System.out.println();
            System.out.println("BitSet.or() bug demonstration");
            System.out.println();
            System.out.print ("Initially: ");
            System.out.print ("s1 = " + s1 + " ");
            System.out.print ("s2 = " + s2 + " ");
            System.out.println("s3 = " + s3);
            System.out.println("doing s1.or(s2)...");
            s1.or(s2);
            System.out.println("s1 = " + s1);
            System.out.println("doing s1.or(s3)...");
            s1.or(s3);
            System.out.println("s1 = " + s1);
          }
      }

            tlindholsunw Timothy Lindholm (Inactive)
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: