Skip to content

Commit 76a514e

Browse files
committed
expand path before adding it to the $CLASSPATH variable
fixes #2216
1 parent 15f651b commit 76a514e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {
6666
paths = context.runtime.newArray(obj).toJavaArray();
6767
}
6868

69+
boolean is1_8 = context.getRuntime().is1_8();
6970
for (IRubyObject path: paths) {
70-
String ss = path.convertToString().toString();
71+
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
72+
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
7173
try {
72-
URL url = getURL(ss);
74+
URL url = getURL(path.convertToString().toString());
7375
getRuntime().getJRubyClassLoader().addURL(url);
7476
} catch (MalformedURLException mue) {
7577
throw getRuntime().newArgumentError(mue.getLocalizedMessage());

test/test_higher_javasupport.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,6 @@ def test_top_level_package_load_doesnt_set_error
710710
# JRUBY-2169
711711
def test_java_class_resource_methods
712712
path = 'test/org/jruby/javasupport/test/'
713-
# workaround for https://github.com/jruby/jruby/issues/2216
714-
path = File.expand_path(path) if ENV_JAVA['user.dir'] != Dir.pwd
715713
$CLASSPATH << path
716714
file = 'test_java_class_resource_methods.properties'
717715

@@ -720,6 +718,7 @@ def test_java_class_resource_methods
720718
# get resource as URL
721719
url = jc.resource_as_url(file)
722720
assert(java.net.URL === url)
721+
assert(url.path == File.expand_path(url.path))
723722
assert(/^foo=bar/ =~ java.io.DataInputStream.new(url.content).read_line)
724723

725724
# get resource as stream

0 commit comments

Comments
 (0)