Yes, I read both the posts. Ideally, I'd like to compile it without modifying the code. I tried the javac -J-Xms512 option, but I get the foll, error:
Error occurred during initialization of VM
Incompatible initial and maximum heap sizes specified
In any case, I need to be increasing the stack size (not heap size), right? It seems like there should be an easy way to configure this or set this as a javac argument option. Thanks for any help.
I've tried the foll values for -Xmx (max heap size - 10m,16m,32m), -Xoss(max java stack size - 256k, 512k, 1024k) and -Xss(max native stack size - 64k,128k,256k,512k). None of them work. I still get the StackOverflowError.
A few clues on what is happening. There are about 800 else-ifs in the if-else-if. I got it to compile when I deleted about 200 else-ifs. Is there a way to get all of it to work?
That's a lot of if-elses and you are obviously straining things. The reason is simple - consider what those if-elses look like if you had all the implied {}'s in there:
if (a)
{
}
else
{
if (b)
{
}
else
{
if (c)
{
}
else
{
// etc
}
}
}
All the context for the first 'if' statement has to be retained while the second 'if' statement is processed, and for the 2nd 'if' while the 3rd 'if' is processed, and so forth. So there is a stack, so if there are enough if-else's it will overflow.
You best option is to try to find another way to process this. Is all this stuff really in the same bean, or can it be refactored? For example, is this Bean constructor really a factory method for a family of Beans that all have one boolean each?