Skip to content
Permalink
Browse files
expand path before adding it to the $CLASSPATH variable
fixes #2216
  • Loading branch information
mkristian committed Dec 3, 2014
1 parent 15f651b commit 76a514eb6d123b16b7c6ab8b5654dccfacf68047
Showing with 5 additions and 4 deletions.
  1. +4 −2 core/src/main/java/org/jruby/RubyClassPathVariable.java
  2. +1 −2 test/test_higher_javasupport.rb
@@ -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());
@@ -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'

@@ -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

0 comments on commit 76a514e

Please sign in to comment.