Skip to content

Commit d8c4f36

Browse files
committed
Put user-supplied options after default options on command-line
1 parent ffcf4c9 commit d8c4f36

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

argparser.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ bool ArgParser::parseArgs(int argc, char *argv[]) {
351351
}
352352

353353
void 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;

argparser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2010 JRuby Team (www.jruby.org).
2+
* Copyright 2009-2012 JRuby Team (www.jruby.org).
33
*/
44

55

@@ -41,7 +41,7 @@ class ArgParser {
4141

4242
bool initPlatformDir();
4343
void prepareOptions();
44-
void setupMaxHeapAndStack();
44+
void setupMaxHeapAndStack(std::list<std::string> userOptions);
4545
void addEnvVarToOptions(std::list<std::string> & optionsList, const char * envvar);
4646
void constructClassPath();
4747
void constructBootClassPath();

spec/launcher_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@
210210
end
211211
end
212212

213+
it "should place user-supplied options after default options" do
214+
args = jruby_launcher_args("-J-Djruby.home=/tmp")
215+
home_args = args.select {|x| x =~ /^-Djruby\.home/ }
216+
home_args.length.should == 2
217+
home_args.last.should == "-Djruby.home=/tmp"
218+
end
219+
213220
it "should print the version" do
214221
jruby_launcher("-Xversion 2>&1").should =~ /Launcher Version #{JRubyLauncher::VERSION}/
215222
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
#ifndef _VERSION_H_
77
#define _VERSION_H_
88

9-
#define JRUBY_LAUNCHER_VERSION "1.0.11"
9+
#define JRUBY_LAUNCHER_VERSION "1.0.12"
1010

1111
#endif // ! _VERSION_H_

0 commit comments

Comments
 (0)