Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2018665 | 1.2.0 | Sheng Liang | P4 | Closed | Fixed | 1.2alpha1 |
Name: dgC58589 Date: 01/16/98
Hello,
I ran into the following situation using JDK 1.1.3 on Solaris and
1.1.4 on Windows. I used a static initializer to allocate a data
structure. So far, so good, but I made an mistake in there which
caused an array overflow.
I didn't notice this at first, since the program continued to work. I
have been able to reduce the situation context to the following small
program:
public class bug {
private static String str = "foo";
private static int[] x;
public static void main(String[] argv) {
System.out.println(str);
}
static {
System.out.println("in static");
x = new int[10];
x[-10]=4711;
str="bar";
}
}
This gives me the following output:
% java bug
in static
foo
The program works however, i.e. an error message is printed if I put
the main routine into a different class and just instantiate the class
`bug'.
Either the RuntimeException ArrayIndexOutOfBoundsException that should
have been raised is not thrown or not correctly handled. The former
would mean that I can access memory via illegal indices that shouldn't
be in my hands, but I guess that in fact the latter case applies.
BTW: VisualAge and kaffe didn't show this strange behaviour, i.e. they
both halted the program with an error message.
Yours
Markus
(Review ID: 23505)
======================================================================
- backported by
-
JDK-2018665 static initializer ignores RunTimeException
-
- Closed
-