I'm trying to define a global constant ImmutableList that is too large for the default stack size limit, and I'm wondering if there's a way to get around it other than passing an aggressive Xss32M
flag to java
.
Here's the code snippet:
import com.google.common.collect.ImmutableList;
import util.FixedRowDefinition;
import java.util.List;
public class FancyConstants {
public static final List<Person> student_list = new ImmutableList.Builder<Person>()
.add(new Person("Amy",12,56))
.add(new Person("Tom",26,79))
.........
.add(...).build()
/* More similar definitions; could be very long */
}
There are roughly 2000 lines like the above, and I guess the reason why the class blows up is that each element is an Object (although very lean).
Is there a way such that I can define student_list
in Java such that it won't cause the StackOverflow
error like I currently observe?