Skip to content

Commit 83044c2

Browse files
committed
get the $CLASSPATH variable right and allow proper URL as well
adjusted some specs to check for path expanded entries. #2216
1 parent 76a514e commit 83044c2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

core/src/main/java/org/jruby/RubyClassPathVariable.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,13 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {
6868

6969
boolean is1_8 = context.getRuntime().is1_8();
7070
for (IRubyObject path: paths) {
71-
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
72-
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
7371
try {
7472
URL url = getURL(path.convertToString().toString());
73+
if (url.getProtocol().equals("file")) {
74+
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
75+
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
76+
url = getURL(path.convertToString().toString());
77+
}
7578
getRuntime().getJRubyClassLoader().addURL(url);
7679
} catch (MalformedURLException mue) {
7780
throw getRuntime().newArgumentError(mue.getLocalizedMessage());

spec/java_integration/globals/classpath_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@
44
describe "<<" do
55
it "accepts an object" do
66
$CLASSPATH << "file"
7-
$CLASSPATH.to_a.include?("file:file").should == true
7+
$CLASSPATH.to_a.include?("file:#{File.expand_path('file')}").should == true
88
end
99

1010
it "accepts an array" do
1111
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) do
1212
$CLASSPATH << Dir.glob("*.jar")
13-
($CLASSPATH.to_a.include?("file:jruby.jar") ||
14-
$CLASSPATH.to_a.include?("file:jruby-complete.jar") ).should == true
13+
($CLASSPATH.to_a.include?("file:#{File.expand_path('jruby.jar')}")).should == true
1514
end
1615
end
1716
end
18-
end
17+
end

0 commit comments

Comments
 (0)