@@ -351,6 +351,9 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
351351}
352352
353353void ArgParser::prepareOptions () {
354+ list<string> userOptions (javaOptions);
355+ javaOptions.clear ();
356+
354357 string option = OPT_JDK_HOME;
355358 option += jdkhome;
356359 javaOptions.push_back (option);
@@ -398,7 +401,7 @@ void ArgParser::prepareOptions() {
398401#endif
399402 javaOptions.push_back (option);
400403
401- setupMaxHeapAndStack ();
404+ setupMaxHeapAndStack (userOptions );
402405
403406 constructBootClassPath ();
404407 constructClassPath ();
@@ -429,13 +432,14 @@ void ArgParser::prepareOptions() {
429432 javaOptions.push_back (option);
430433 }
431434
435+ javaOptions.insert (javaOptions.end (), userOptions.begin (), userOptions.end ());
432436}
433437
434- void ArgParser::setupMaxHeapAndStack () {
438+ void ArgParser::setupMaxHeapAndStack (list<string> userOptions ) {
435439 // Hard-coded 500m, 2048k is for consistency with jruby shell script.
436440 string heapSize (" 500m" ), stackSize (" 2048k" );
437441 bool maxHeap = false , maxStack = false ;
438- for (list<string>::iterator it = javaOptions .begin (); it != javaOptions .end (); it++) {
442+ for (list<string>::iterator it = userOptions .begin (); it != userOptions .end (); it++) {
439443 if (!maxHeap && strncmp (" -Xmx" , it->c_str (), 4 ) == 0 ) {
440444 heapSize = it->substr (4 , it->size () - 4 );
441445 maxHeap = true ;
0 commit comments