Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
expand path before adding it to the $CLASSPATH variable
fixes #2216
  • Loading branch information
mkristian committed Dec 3, 2014
1 parent 15f651b commit 76a514e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/RubyClassPathVariable.java
Expand Up @@ -66,10 +66,12 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {
paths = context.runtime.newArray(obj).toJavaArray();
}

boolean is1_8 = context.getRuntime().is1_8();
for (IRubyObject path: paths) {
String ss = path.convertToString().toString();
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
try {
URL url = getURL(ss);
URL url = getURL(path.convertToString().toString());
getRuntime().getJRubyClassLoader().addURL(url);
} catch (MalformedURLException mue) {
throw getRuntime().newArgumentError(mue.getLocalizedMessage());
Expand Down
3 changes: 1 addition & 2 deletions test/test_higher_javasupport.rb
Expand Up @@ -710,8 +710,6 @@ def test_top_level_package_load_doesnt_set_error
# JRUBY-2169
def test_java_class_resource_methods
path = 'test/org/jruby/javasupport/test/'
# workaround for https://github.com/jruby/jruby/issues/2216
path = File.expand_path(path) if ENV_JAVA['user.dir'] != Dir.pwd
$CLASSPATH << path
file = 'test_java_class_resource_methods.properties'

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

# get resource as stream
Expand Down

0 comments on commit 76a514e

Please sign in to comment.