-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
14
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
correct code throws an exception
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
assigned value 2, to array's element at index 3
ACTUAL -
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 1
at org.unirail.Main.main(Main.java:13)
---------- BEGIN SOURCE ----------
public class Main {
static int[] array = new int[1];
static int boo() {
array = new int[10];
return 3;
}
public static void main( String[] args ) {
array[boo()] = 2;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public class Main {
static int[] array = new int[1];
static int boo() {
array = new int[10];
return 3;
}
public static void main( String[] args ) {
int i = boo();
array[i] = 2;
}
}
FREQUENCY : always
correct code throws an exception
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run code
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
assigned value 2, to array's element at index 3
ACTUAL -
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 1
at org.unirail.Main.main(Main.java:13)
---------- BEGIN SOURCE ----------
public class Main {
static int[] array = new int[1];
static int boo() {
array = new int[10];
return 3;
}
public static void main( String[] args ) {
array[boo()] = 2;
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public class Main {
static int[] array = new int[1];
static int boo() {
array = new int[10];
return 3;
}
public static void main( String[] args ) {
int i = boo();
array[i] = 2;
}
}
FREQUENCY : always