-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
None
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
We generate a unit test automatically, and the test failed. The test case is as below:
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
@Test
public void test_setTo(){
long long1 = 1L;
long long2 = 0L;
jdk.nashorn.internal.runtime.BitVector bitVector0 = new jdk.nashorn.internal.runtime.BitVector(long2);
bitVector0.setTo(long1);
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
do not throw ArrayIndexOutOfBoundsException
ACTUAL -
java.lang.ArrayIndexOutOfBoundsException: 0
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.BitVector.setTo(BitVector.java:169)
---------- BEGIN SOURCE ----------
/**
* Sets all bits in the vector up to the length.
*
* @param length max bit where to stop setting bits
*/
public void setTo(final long length) {
if (0 < length) {
final int lastWord = (int)(length >> BITSHIFT);
final long lastBits = (1L << (int)(length & BITMASK)) - 1L;
Arrays.fill(bits, 0, lastWord, ~0L);
if (lastBits != 0L) {
bits[lastWord] |= lastBits;
}
}
}
---------- END SOURCE ----------
FREQUENCY : occasionally
We generate a unit test automatically, and the test failed. The test case is as below:
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
@Test
public void test_setTo(){
long long1 = 1L;
long long2 = 0L;
jdk.nashorn.internal.runtime.BitVector bitVector0 = new jdk.nashorn.internal.runtime.BitVector(long2);
bitVector0.setTo(long1);
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
do not throw ArrayIndexOutOfBoundsException
ACTUAL -
java.lang.ArrayIndexOutOfBoundsException: 0
at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.BitVector.setTo(BitVector.java:169)
---------- BEGIN SOURCE ----------
/**
* Sets all bits in the vector up to the length.
*
* @param length max bit where to stop setting bits
*/
public void setTo(final long length) {
if (0 < length) {
final int lastWord = (int)(length >> BITSHIFT);
final long lastBits = (1L << (int)(length & BITMASK)) - 1L;
Arrays.fill(bits, 0, lastWord, ~0L);
if (lastBits != 0L) {
bits[lastWord] |= lastBits;
}
}
}
---------- END SOURCE ----------
FREQUENCY : occasionally