Commit 29123a37 by Mark Wielaard Committed by Mark Wielaard

BitSet.java (BitSet(int)): if nbits < 0 throw NegativeArraySizeException

        * java/util/BitSet.java (BitSet(int)): if nbits < 0 throw
        NegativeArraySizeException
        (clear(int)): Use sign extended shift.
        (flip(int)): Likewise.
        (get(int)): Likewise.
        (nextClearBit(int)): Likewise.
        (nextSetBit(int)): Likewise.
        (set(int)): Likewise.

From-SVN: r51701
parent bcf88f9b
2002-04-01 Mark Wielaard <mark@klomp.org> 2002-04-01 Mark Wielaard <mark@klomp.org>
* java/util/BitSet.java (BitSet(int)): if nbits < 0 throw
NegativeArraySizeException
(clear(int)): Use sign extended shift.
(flip(int)): Likewise.
(get(int)): Likewise.
(nextClearBit(int)): Likewise.
(nextSetBit(int)): Likewise.
(set(int)): Likewise.
2002-04-01 Mark Wielaard <mark@klomp.org>
* mauve-libgcj: Add JDK1.3, JDK1.4, JLS1.2 tests, remove ignored tests * mauve-libgcj: Add JDK1.3, JDK1.4, JLS1.2 tests, remove ignored tests
that can be compiled now and add testsuite crashers to ignore list. that can be compiled now and add testsuite crashers to ignore list.
......
...@@ -102,6 +102,9 @@ public class BitSet implements Cloneable, Serializable ...@@ -102,6 +102,9 @@ public class BitSet implements Cloneable, Serializable
*/ */
public BitSet(int nbits) public BitSet(int nbits)
{ {
if (nbits < 0)
throw new NegativeArraySizeException();
int length = nbits >>> 6; int length = nbits >>> 6;
if ((nbits & LONG_MASK) != 0) if ((nbits & LONG_MASK) != 0)
++length; ++length;
...@@ -195,7 +198,7 @@ public class BitSet implements Cloneable, Serializable ...@@ -195,7 +198,7 @@ public class BitSet implements Cloneable, Serializable
*/ */
public void clear(int pos) public void clear(int pos)
{ {
int offset = pos >>> 6; int offset = pos >> 6;
ensure(offset); ensure(offset);
// ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException, // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
// so we'll just let that be our exception. // so we'll just let that be our exception.
...@@ -289,7 +292,7 @@ public class BitSet implements Cloneable, Serializable ...@@ -289,7 +292,7 @@ public class BitSet implements Cloneable, Serializable
*/ */
public void flip(int index) public void flip(int index)
{ {
int offset = index >>> 6; int offset = index >> 6;
ensure(offset); ensure(offset);
// ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException, // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
// so we'll just let that be our exception. // so we'll just let that be our exception.
...@@ -335,7 +338,7 @@ public class BitSet implements Cloneable, Serializable ...@@ -335,7 +338,7 @@ public class BitSet implements Cloneable, Serializable
*/ */
public boolean get(int pos) public boolean get(int pos)
{ {
int offset = pos >>> 6; int offset = pos >> 6;
if (offset >= bits.length) if (offset >= bits.length)
return false; return false;
// ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException, // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
...@@ -498,7 +501,7 @@ public class BitSet implements Cloneable, Serializable ...@@ -498,7 +501,7 @@ public class BitSet implements Cloneable, Serializable
*/ */
public int nextClearBit(int from) public int nextClearBit(int from)
{ {
int offset = from >>> 6; int offset = from >> 6;
long mask = 1L << from; long mask = 1L << from;
while (offset < bits.length) while (offset < bits.length)
{ {
...@@ -535,7 +538,7 @@ public class BitSet implements Cloneable, Serializable ...@@ -535,7 +538,7 @@ public class BitSet implements Cloneable, Serializable
*/ */
public int nextSetBit(int from) public int nextSetBit(int from)
{ {
int offset = from >>> 6; int offset = from >> 6;
long mask = 1L << from; long mask = 1L << from;
while (offset < bits.length) while (offset < bits.length)
{ {
...@@ -583,7 +586,7 @@ public class BitSet implements Cloneable, Serializable ...@@ -583,7 +586,7 @@ public class BitSet implements Cloneable, Serializable
*/ */
public void set(int pos) public void set(int pos)
{ {
int offset = pos >>> 6; int offset = pos >> 6;
ensure(offset); ensure(offset);
// ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException, // ArrayIndexOutOfBoundsException subclasses IndexOutOfBoundsException,
// so we'll just let that be our exception. // so we'll just let that be our exception.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment