Skip to content

Commit

Permalink
Make sure that jars that are symlinked to extensionless files are loa…
Browse files Browse the repository at this point in the history
…ded correctly
  • Loading branch information
Dmitry Ratnikov committed Jun 24, 2013
1 parent e25db63 commit 84e2862
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/org/jruby/runtime/load/LoadService.java
Expand Up @@ -1092,7 +1092,8 @@ protected Library createLibrary(SearchState state, LoadServiceResource resource)
if (resource == null) { if (resource == null) {
return null; return null;
} }
String file = state.loadName; String file = resource.getName();
String location = state.loadName;
if (file.endsWith(".so") || file.endsWith(".dll") || file.endsWith(".bundle")) { if (file.endsWith(".so") || file.endsWith(".dll") || file.endsWith(".bundle")) {
if (runtime.getInstanceConfig().isCextEnabled()) { if (runtime.getInstanceConfig().isCextEnabled()) {
return new CExtension(resource); return new CExtension(resource);
Expand All @@ -1104,7 +1105,7 @@ protected Library createLibrary(SearchState state, LoadServiceResource resource)
} else if (file.endsWith(".class")) { } else if (file.endsWith(".class")) {
return new JavaCompiledScript(resource); return new JavaCompiledScript(resource);
} else { } else {
return new ExternalScript(resource, file); return new ExternalScript(resource, location);
} }
} }


Expand Down
17 changes: 17 additions & 0 deletions test/test_load.rb
Expand Up @@ -262,4 +262,21 @@ def test_cwd_plus_dotdot_jar_loading
$hello $hello
}) })
end end

def test_symlinked_jar
Dir.chdir('test') do
FileUtils.cp 'jar_with_ruby_files.jar', 'jarwithoutextension' unless File.exists?('jarwithoutextension')
File.symlink 'jarwithoutextension', 'symlink.jar' unless File.symlink?('symlink.jar')
end

assert_in_sub_runtime %{
require 'test/symlink.jar'
}
ensure
Dir.chdir('test') do
[ 'jarwithoutextension', 'symlink.jar' ].each do |file|
File.delete(file)
end
end
end
end end

0 comments on commit 84e2862

Please sign in to comment.