Skip to content
Permalink
Browse files
get the $CLASSPATH variable right and allow proper URL as well
adjusted some specs to check for path expanded entries. #2216
  • Loading branch information
mkristian committed Dec 3, 2014
1 parent 76a514e commit 83044c2c062e5cd0c67f71b7ebf4ab739aa9ccc2
Showing with 8 additions and 6 deletions.
  1. +5 −2 core/src/main/java/org/jruby/RubyClassPathVariable.java
  2. +3 −4 spec/java_integration/globals/classpath_spec.rb
@@ -68,10 +68,13 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {

boolean is1_8 = context.getRuntime().is1_8();
for (IRubyObject path: paths) {
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
try {
URL url = getURL(path.convertToString().toString());
if (url.getProtocol().equals("file")) {
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
url = getURL(path.convertToString().toString());
}
getRuntime().getJRubyClassLoader().addURL(url);
} catch (MalformedURLException mue) {
throw getRuntime().newArgumentError(mue.getLocalizedMessage());
@@ -4,15 +4,14 @@
describe "<<" do
it "accepts an object" do
$CLASSPATH << "file"
$CLASSPATH.to_a.include?("file:file").should == true
$CLASSPATH.to_a.include?("file:#{File.expand_path('file')}").should == true
end

it "accepts an array" do
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) do
$CLASSPATH << Dir.glob("*.jar")
($CLASSPATH.to_a.include?("file:jruby.jar") ||
$CLASSPATH.to_a.include?("file:jruby-complete.jar") ).should == true
($CLASSPATH.to_a.include?("file:#{File.expand_path('jruby.jar')}")).should == true
end
end
end
end
end

0 comments on commit 83044c2

Please sign in to comment.