From 84e286266e7fda6ad69822bd9d01709759c881f8 Mon Sep 17 00:00:00 2001 From: Dmitry Ratnikov Date: Mon, 24 Jun 2013 18:29:16 -0400 Subject: [PATCH] Make sure that jars that are symlinked to extensionless files are loaded correctly --- src/org/jruby/runtime/load/LoadService.java | 5 +++-- test/test_load.rb | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/org/jruby/runtime/load/LoadService.java b/src/org/jruby/runtime/load/LoadService.java index f314fbc5032..6276fd9e1ec 100644 --- a/src/org/jruby/runtime/load/LoadService.java +++ b/src/org/jruby/runtime/load/LoadService.java @@ -1092,7 +1092,8 @@ protected Library createLibrary(SearchState state, LoadServiceResource resource) if (resource == 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 (runtime.getInstanceConfig().isCextEnabled()) { return new CExtension(resource); @@ -1104,7 +1105,7 @@ protected Library createLibrary(SearchState state, LoadServiceResource resource) } else if (file.endsWith(".class")) { return new JavaCompiledScript(resource); } else { - return new ExternalScript(resource, file); + return new ExternalScript(resource, location); } } diff --git a/test/test_load.rb b/test/test_load.rb index 28a65d090c4..b352231ae5e 100644 --- a/test/test_load.rb +++ b/test/test_load.rb @@ -262,4 +262,21 @@ def test_cwd_plus_dotdot_jar_loading $hello }) 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