Skip to content

Commit aec3e5b

Browse files
committed
Use -cp for separate processes which will expand wildcard entries
1 parent 11db685 commit aec3e5b

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

argparser.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const char *ArgParser::OPT_JDK_HOME = "-Djdk.home=";
5555
const char *ArgParser::OPT_JRUBY_HOME = "-Djruby.home=";
5656
const char *ArgParser::OPT_JRUBY_COMMAND_NAME = "-Dsun.java.command=";
5757

58+
const char *ArgParser::OPT_CMDLINE_CLASS_PATH = "-cp";
5859
const char *ArgParser::OPT_CLASS_PATH = "-Djava.class.path=";
5960
const char *ArgParser::OPT_BOOT_CLASS_PATH = "-Xbootclasspath/a:";
6061

@@ -65,7 +66,7 @@ const char *ArgParser::MAIN_CLASS = "org/jruby/Main";
6566
const char *ArgParser::DEFAULT_EXECUTABLE = "jruby";
6667

6768
ArgParser::ArgParser()
68-
: separateProcess(false)
69+
: separateProcess(true)
6970
, nailgunClient(false)
7071
, noBootClassPath(false)
7172
, printCommandLine(false)
@@ -433,9 +434,15 @@ void ArgParser::prepareOptions() {
433434
option += cmdName;
434435
javaOptions.push_back(option);
435436

436-
option = OPT_CLASS_PATH;
437-
option += classPath;
438-
javaOptions.push_back(option);
437+
// When launching a separate process, use '-cp' which expands embedded wildcards
438+
if (separateProcess) {
439+
javaOptions.push_back(OPT_CMDLINE_CLASS_PATH);
440+
javaOptions.push_back(classPath);
441+
} else {
442+
option = OPT_CLASS_PATH;
443+
option += classPath;
444+
javaOptions.push_back(option);
445+
}
439446

440447
if (!bootClassPath.empty()) {
441448
option = OPT_BOOT_CLASS_PATH;

argparser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class ArgParser {
1919
static const char *OPT_JRUBY_HOME;
2020
static const char *OPT_JRUBY_COMMAND_NAME;
2121

22+
static const char *OPT_CMDLINE_CLASS_PATH;
2223
static const char *OPT_CLASS_PATH;
2324
static const char *OPT_BOOT_CLASS_PATH;
2425

platformlauncher.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ extern "C" int nailgunClientMain(int argc, char *argv[], char *env[]);
5454
PlatformLauncher::PlatformLauncher()
5555
: ArgParser()
5656
, suppressConsole(false)
57+
, separateProcess(false)
5758
{
5859
}
5960

spec/launcher_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,15 @@
102102

103103
it "should add the contents of the CLASSPATH environment variable" do
104104
with_environment "CLASSPATH" => "some.jar" do
105-
classpath_arg = jruby_launcher_args("").detect{|a| a =~ /java\.class\.path/}
106-
classpath_arg.should =~ /-Djava.class.path=.*some.jar/
105+
classpath_arg(jruby_launcher_args("")).should =~ /some.jar/
107106
end
108107
end
109108

110109
it "should add the classpath elements in proper order" do
111110
s = File::PATH_SEPARATOR
112111
with_environment "CLASSPATH" => "some-env.jar" do
113-
classpath_arg = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar").detect{|a| a =~ /java\.class\.path/}
114-
classpath_arg.should =~ /-Djava.class.path=some.jar.*#{s}some-env.jar#{s}some-other.jar/
112+
args = jruby_launcher_args("-Xcp:a some-other.jar -Xcp:p some.jar")
113+
classpath_arg(args).should =~ /some.jar.*#{s}some-env.jar#{s}some-other.jar/
115114
end
116115
end
117116

@@ -189,7 +188,7 @@
189188

190189
# JRUBY-4709
191190
it "should include a bare : or ; at the end of the classpath, to include PWD in the path" do
192-
jruby_launcher_args("-Xnobootclasspath -e true").grep(/java\.class\.path/).first.should =~
191+
classpath_arg(jruby_launcher_args("-Xnobootclasspath -e true")).should =~
193192
if windows?
194193
/;$/
195194
else

spec/spec_helper.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ def windows?
4545
WINDOWS
4646
end
4747

48+
def classpath_arg(args)
49+
index = args.index("-cp")
50+
index.should > 0
51+
args[index + 1]
52+
end
53+
4854
def with_environment(pairs = {})
4955
prev_env = {}
5056
pairs.each_pair do |k,v|

0 commit comments

Comments
 (0)