Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions hbase-shell/src/main/ruby/irb/hirb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,19 @@ module HBaseLoader
##
# Determine the loadable path for a given filename by searching through $LOAD_PATH
#
# This serves a similar purpose to IRB::IrbLoader#search_file_from_ruby_path, but uses JRuby's
# loader, which allows us to find special paths like "uri:classloader" inside of a Jar.
# Uses $LOAD_PATH.resolve_feature_path, which resolves files on disk as well as
# entries inside jars on the classpath. Returns nil on miss.
#
# @param [String] filename
# @return [String] path
def self.path_for_load(filename)
return File.absolute_path(filename) if File.exist? filename

# Get JRuby's LoadService from the global (singleton) instance of the runtime
# (org.jruby.Ruby), which allows us to use JRuby's tools for searching the load path.
runtime = org.jruby.Ruby.getGlobalRuntime
loader = runtime.getLoadService
search_state = loader.findFileForLoad filename
raise LoadError, "no such file to load -- #{filename}" if search_state.library.nil?
resolved = $LOAD_PATH.resolve_feature_path(filename)
raise LoadError, "no such file to load -- #{filename}" if resolved.nil?

search_state.loadName
_type, path = resolved
path
end

##
Expand Down