Name: yyT116575 Date: 03/21/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
When compiling switch statements with at least 3 cases, where one of the cases
is equal to Integer.MAX_VALUE, javac runs out of memory. This doesn't happen if
there are only two cases, and it doesn't happen if the largest one is less than
Integer.MAX_VALUE, even by 1. It also doesn't appear to happen if the two
smaller cases are "relatively small". For instance, the problem occurs if the
cases are <0x7ffffffd,0x7ffffffe,0x7fffffff>, but not, for instance, if they are
<0,1,0x7fffffff>. It also does NOT occur if the cases are
<0x7ffffffc,0x7ffffffd,0x7ffffffe>.
The exact error message I get is:
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError
<<no stack trace available>>
Source code to reproduce it follows:
===================================
public class foo {
static void main(String args[]) {
int i=0;
switch(i) {
case CONSTANT1:
System.out.println("foo1");
break;
case CONSTANT2:
System.out.println("foo1");
break;
case CONSTANT3:
System.out.println("foo3");
break;
}
}
static final int CONSTANT1 = 0x7fffffff;
static final int CONSTANT2 = 0x7ffffffe;
static final int CONSTANT3 = 0x7ffffffd;
}
=====================================
(Review ID: 119257)
======================================================================
- duplicates
-
JDK-4368309 Simple switch statement with large case values gives OutOfMemoryError in javac
-
- Closed
-