Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2023648 | 1.4.0 | Tim Bell | P5 | Resolved | Fixed | beta |
I think I may have found a place of improvement for jdb, i'm using jdk
1.2.beta4 on WindowsNT.
I have created an array of integers in class TestQ by doing something
like this
int[] order_of_store = new int[60];
This array gets populated with data and when I dump it in jdb I get
something like this:
main[1] dump TestQ.order_of_store
TestQ.order_of_store = { 65, 66, 67, ... } {
}
Now say I want a specific element for that array. say element 61 which
is out of bounds.
main[1] dump TestQ.order_of_store[61]
61 is out of bounds for { 65, 66, 67, ... }
Shouldn't the debugger state that "61 is out of bounds for
TestQ.order_of_store" instead of printing the array's contents?
tim.bell@Eng 2000-07-26
Here is a test case and an example stack trace:
% /usr/bin/pr -n DumpArrayBoundsTarg.java
Jul 26 17:55 2000 DumpArrayBoundsTarg.java Page 1
1 class DumpArrayBoundsTarg {
2 static final int LENGTH = 60;
3 int[] order_of_store = null;
4
5 DumpArrayBoundsTarg (int arraySize) {
6 order_of_store = new int[arraySize];
7 for (int i = 0; i < order_of_store.length; i++) {
8 order_of_store[i] = i;
9 }
10 }
11
12 static void main(String [] args) {
13 DumpArrayBoundsTarg myTest =
14 new DumpArrayBoundsTarg(DumpArrayBoundsTarg.LENGTH);
15 int j = myTest.order_of_store[0];
16 int k = myTest.order_of_store[DumpArrayBoundsTarg.LENGTH - 1];
17 }
18 }
% javac -g DumpArrayBoundsTarg.java
% jdb -J-showversion DumpArrayBoundsTarg
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-I)
Java HotSpot (TM) Client VM (build 1.3-I, interpreted mode)
Initializing jdb...
> stop at DumpArrayBoundsTarg:16
Deferring breakpoint DumpArrayBoundsTarg:16.
It will be set after the class is loaded.
> run
run DumpArrayBoundsTarg
Java HotSpot (TM) Client VM warning: Setting of property "java.compiler" is ignored
Java HotSpot (TM) Client VM warning: Ignoring breakpoint on java.lang.Thread.resume
VM Started: > Set deferred breakpoint DumpArrayBoundsTarg:16
Breakpoint hit: thread="main", DumpArrayBoundsTarg.main(), line=16, bci=17
16 int k = myTest.order_of_store[DumpArrayBoundsTarg.LENGTH - 1];
main[1] dump myTest.order_of_store[61]
java.lang.IndexOutOfBoundsException: Invalid array range: 61 to 61
at com.sun.tools.jdi.ArrayReferenceImpl.validateArrayAccess(ArrayReferenceImpl.java:83)
at com.sun.tools.jdi.ArrayReferenceImpl.getValues(ArrayReferenceImpl.java:90)
at com.sun.tools.jdi.ArrayReferenceImpl.getValue(ArrayReferenceImpl.java:62)
at com.sun.tools.example.debug.expr.LValue$LValueArrayElement.getValue(LValue.java:374)
at com.sun.tools.example.debug.expr.ExpressionParser.evaluate(ExpressionParser.java:58)
at com.sun.tools.example.debug.tty.Commands.evaluate(Commands.java:65)
at com.sun.tools.example.debug.tty.Commands.doPrint(Commands.java:1355)
at com.sun.tools.example.debug.tty.Commands$3.run(Commands.java:1388)
1.2.beta4 on WindowsNT.
I have created an array of integers in class TestQ by doing something
like this
int[] order_of_store = new int[60];
This array gets populated with data and when I dump it in jdb I get
something like this:
main[1] dump TestQ.order_of_store
TestQ.order_of_store = { 65, 66, 67, ... } {
}
Now say I want a specific element for that array. say element 61 which
is out of bounds.
main[1] dump TestQ.order_of_store[61]
61 is out of bounds for { 65, 66, 67, ... }
Shouldn't the debugger state that "61 is out of bounds for
TestQ.order_of_store" instead of printing the array's contents?
tim.bell@Eng 2000-07-26
Here is a test case and an example stack trace:
% /usr/bin/pr -n DumpArrayBoundsTarg.java
Jul 26 17:55 2000 DumpArrayBoundsTarg.java Page 1
1 class DumpArrayBoundsTarg {
2 static final int LENGTH = 60;
3 int[] order_of_store = null;
4
5 DumpArrayBoundsTarg (int arraySize) {
6 order_of_store = new int[arraySize];
7 for (int i = 0; i < order_of_store.length; i++) {
8 order_of_store[i] = i;
9 }
10 }
11
12 static void main(String [] args) {
13 DumpArrayBoundsTarg myTest =
14 new DumpArrayBoundsTarg(DumpArrayBoundsTarg.LENGTH);
15 int j = myTest.order_of_store[0];
16 int k = myTest.order_of_store[DumpArrayBoundsTarg.LENGTH - 1];
17 }
18 }
% javac -g DumpArrayBoundsTarg.java
% jdb -J-showversion DumpArrayBoundsTarg
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-I)
Java HotSpot (TM) Client VM (build 1.3-I, interpreted mode)
Initializing jdb...
> stop at DumpArrayBoundsTarg:16
Deferring breakpoint DumpArrayBoundsTarg:16.
It will be set after the class is loaded.
> run
run DumpArrayBoundsTarg
Java HotSpot (TM) Client VM warning: Setting of property "java.compiler" is ignored
Java HotSpot (TM) Client VM warning: Ignoring breakpoint on java.lang.Thread.resume
VM Started: > Set deferred breakpoint DumpArrayBoundsTarg:16
Breakpoint hit: thread="main", DumpArrayBoundsTarg.main(), line=16, bci=17
16 int k = myTest.order_of_store[DumpArrayBoundsTarg.LENGTH - 1];
main[1] dump myTest.order_of_store[61]
java.lang.IndexOutOfBoundsException: Invalid array range: 61 to 61
at com.sun.tools.jdi.ArrayReferenceImpl.validateArrayAccess(ArrayReferenceImpl.java:83)
at com.sun.tools.jdi.ArrayReferenceImpl.getValues(ArrayReferenceImpl.java:90)
at com.sun.tools.jdi.ArrayReferenceImpl.getValue(ArrayReferenceImpl.java:62)
at com.sun.tools.example.debug.expr.LValue$LValueArrayElement.getValue(LValue.java:374)
at com.sun.tools.example.debug.expr.ExpressionParser.evaluate(ExpressionParser.java:58)
at com.sun.tools.example.debug.tty.Commands.evaluate(Commands.java:65)
at com.sun.tools.example.debug.tty.Commands.doPrint(Commands.java:1355)
at com.sun.tools.example.debug.tty.Commands$3.run(Commands.java:1388)
- backported by
-
JDK-2023648 TTY: unclear error message on array index out of bounds
-
- Resolved
-