Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d3c010683fe9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c94088895ee3
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 20, 2014

  1. Add simple setter so we can more easily figure out what is setting in…

    …correct LOADED_FEATURES value
    enebo committed Sep 20, 2014
    Copy the full SHA
    11e3b3a View commit details
  2. Fix invalid test where it was supposed to run inproc but instead fail…

    …ed to non-inproc because it contains special characters which would disable in-proc execution (like ";")
    enebo committed Sep 20, 2014
    Copy the full SHA
    c940888 View commit details
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ public FoundLibrary findBySearchState(LoadService.SearchState state) {
FoundLibrary lib = findLibrary(state.searchFile, state.suffixType);
if (lib != null) {
state.library = lib;
state.loadName = lib.getLoadName();
state.setLoadName(lib.getLoadName());
}
return lib;
}
28 changes: 16 additions & 12 deletions core/src/main/java/org/jruby/runtime/load/LoadService.java
Original file line number Diff line number Diff line change
@@ -377,7 +377,7 @@ public void loadFromClassLoader(ClassLoader classLoader, String file, boolean wr
Library library = null;
LoadServiceResource resource = getClassPathResource(classLoader, file);
if (resource != null) {
state.loadName = resolveLoadName(resource, file);
state.setLoadName(resolveLoadName(resource, file));
library = createLibrary(state, resource);
}
if (library == null) {
@@ -898,6 +898,10 @@ public void prepareLoadSearch(final String file) {
}
}

public void setLoadName(String loadName) {
this.loadName = loadName;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -1013,7 +1017,7 @@ protected Library findBuiltinLibrary(SearchState state, String baseName, SuffixT
String namePlusSuffix = baseName + suffix;
debugLogTry( "builtinLib", namePlusSuffix );
if (builtinLibraries.containsKey(namePlusSuffix)) {
state.loadName = namePlusSuffix;
state.setLoadName(namePlusSuffix);
Library lib = builtinLibraries.get(namePlusSuffix);
debugLogFound( "builtinLib", namePlusSuffix );
return lib;
@@ -1058,7 +1062,7 @@ protected Library findLibraryWithClassloaders(SearchState state, String baseName
String file = baseName + suffix;
LoadServiceResource resource = findFileInClasspath(file);
if (resource != null) {
state.loadName = resolveLoadName(resource, file);
state.setLoadName(resolveLoadName(resource, file));
return createLibrary(state, resource);
}
}
@@ -1101,7 +1105,7 @@ protected LoadServiceResource tryResourceFromCWD(SearchState state, String baseN
boolean absolute = true;
foundResource = new LoadServiceResource(file, getFileName(file, namePlusSuffix), absolute);
debugLogFound(foundResource);
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
break;
}
} catch (IllegalArgumentException illArgEx) {
@@ -1154,7 +1158,7 @@ protected LoadServiceResource tryResourceFromHome(SearchState state, String base
if (file.isFile() && file.isAbsolute() && file.canRead()) {
boolean absolute = true;

state.loadName = file.getPath();
state.setLoadName(file.getPath());
foundResource = new LoadServiceResource(file, state.loadName, absolute);
debugLogFound(foundResource);
break;
@@ -1193,7 +1197,7 @@ protected LoadServiceResource tryResourceFromJarURL(SearchState state, String ba
throw runtime.newIOErrorFromException(e);
}
if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
break; // end suffix iteration
}
}
@@ -1217,7 +1221,7 @@ protected LoadServiceResource tryResourceFromJarURL(SearchState state, String ba
throw runtime.newIOErrorFromException(e);
} catch(Exception e) {}
if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
break; // end suffix iteration
}
}
@@ -1235,7 +1239,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
foundResource = tryResourceFromDotSlash(state, baseName, suffixType);

if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, foundResource.getName());
state.setLoadName(resolveLoadName(foundResource, foundResource.getName()));
}

// not found, don't bother with load path
@@ -1247,7 +1251,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
foundResource = tryResourceFromHome(state, baseName, suffixType);

if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, foundResource.getName());
state.setLoadName(resolveLoadName(foundResource, foundResource.getName()));
}

// not found, don't bother with load path
@@ -1261,7 +1265,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
foundResource = tryResourceAsIs(namePlusSuffix);

if (foundResource != null) {
state.loadName = resolveLoadName(foundResource, namePlusSuffix);
state.setLoadName(resolveLoadName(foundResource, namePlusSuffix));
return foundResource;
}
}
@@ -1282,7 +1286,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
if(ss.startsWith("./")) {
ss = ss.substring(2);
}
state.loadName = resolveLoadName(foundResource, ss);
state.setLoadName(resolveLoadName(foundResource, ss));
break Outer;
}
} else {
@@ -1304,7 +1308,7 @@ protected LoadServiceResource tryResourceFromLoadPathOrURL(SearchState state, St
if(ss.startsWith("./")) {
ss = ss.substring(2);
}
state.loadName = resolveLoadName(foundResource, ss);
state.setLoadName(resolveLoadName(foundResource, ss));
break Outer; // end suffix iteration
}
}
23 changes: 15 additions & 8 deletions test/test_command_line_switches.rb
Original file line number Diff line number Diff line change
@@ -366,21 +366,23 @@ def test_rubyopts_with_require
ENV['RUBYOPT'] = rubyopt_org
end

def test_inproc_execute_with_globs
args = %{-Xlaunch.inproc=true -e 'system %{jruby -e "p ARGV.sort" test/dir{1,2}/target*}'}
assert_equal %{["test/dir1/target.rb", "test/dir2/target.class"]\n}, jruby(args)
end

# JRUBY-5517
def test_rubyopts_benchmark_cleared_in_child
rubyopt_org = ENV['RUBYOPT']
ENV['RUBYOPT'] = '-r benchmark'

# first subprocess will be "real", second should launch in-process
# this will test whether in-process child is getting proper env for RUBYOPT
args = %{-Xlaunch.inproc=true -e "p defined?(Benchmark) != nil; ENV[%{RUBYOPT}] = nil; system %{bin/jruby -e 'p defined?(Benchmark) != nil'}"}

assert_equal "true\nfalse\n", jruby(args)
script = <<-EOS
p defined?(Benchmark) != nil
ENV[%{RUBYOPT}] = nil
system %{bin/jruby -e 'p defined?(Benchmark) != nil'}
EOS
with_jruby_shell_spawning do
with_temp_script(script) do |s|
assert_equal "true\nfalse\n", jruby("#{s.path}")
end
end
ensure
ENV['RUBYOPT'] = rubyopt_org
end
@@ -403,4 +405,9 @@ def test_rubyopts_is_not_used_to_set_the_script
ensure
ENV['RUBYOPT'] = rubyopt
end

def test_inproc_execute_with_globs
args = %{-Xlaunch.inproc=true -e 'system %{jruby -e "p ARGV.sort" test/dir{1,2}/target*}'}
assert_equal %{["test/dir1/target.rb", "test/dir2/target.class"]\n}, jruby(args)
end
end