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: fffb9e39bedf
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e358cd7c1aa0
Choose a head ref
  • 5 commits
  • 27 files changed
  • 1 contributor

Commits on Mar 31, 2015

  1. use uri:classloader:/ to load kernel

    and let the protocol classpath: search on uri:classloader:/ or on LOAD_PATH
    mkristian committed Mar 31, 2015
    Copy the full SHA
    e7218ea View commit details
  2. Copy the full SHA
    e9fb65c View commit details
  3. ensure relative paths do NOT load unless "." is on $LOAD_PATH

    there is an extra search on "." necessary otherwise the relative path
    will be found via the classloader. the regular mri spec does not fail
    since current directory in java is independent from the current directory
    in ruby
    mkristian committed Mar 31, 2015
    Copy the full SHA
    111011d View commit details
  4. skip test which ensure current directory is NOT on loadpath

    old load-service will find it. new load-service will not find it.
    mkristian committed Mar 31, 2015
    Copy the full SHA
    d25cc3d View commit details
  5. Copy the full SHA
    e358cd7 View commit details
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -154,9 +154,8 @@ public IRubyObject initialize19(ThreadContext context, IRubyObject arg) {
private static List<ByteList> dirGlobs(ThreadContext context, String cwd, IRubyObject[] args, int flags) {
List<ByteList> dirs = new ArrayList<ByteList>();

POSIX posix = context.runtime.getPosix();
for (int i = 0; i < args.length; i++) {
dirs.addAll(Dir.push_glob(posix, cwd, globArgumentAsByteList(context, args[i]), flags));
dirs.addAll(Dir.push_glob(context.runtime, cwd, globArgumentAsByteList(context, args[i]), flags));
}

return dirs;
@@ -195,7 +194,7 @@ public static IRubyObject aref(ThreadContext context, IRubyObject recv, IRubyObj
Ruby runtime = context.runtime;
List<ByteList> dirs;
if (args.length == 1) {
dirs = Dir.push_glob(runtime.getPosix(), getCWD(runtime), globArgumentAsByteList(context, args[0]), 0);
dirs = Dir.push_glob(runtime, getCWD(runtime), globArgumentAsByteList(context, args[0]), 0);
} else {
dirs = dirGlobs(context, getCWD(runtime), args, 0);
}
@@ -221,7 +220,7 @@ public static IRubyObject glob(ThreadContext context, IRubyObject recv, IRubyObj
List<ByteList> dirs;
IRubyObject tmp = args[0].checkArrayType();
if (tmp.isNil()) {
dirs = Dir.push_glob(runtime.getPosix(), runtime.getCurrentDirectory(), globArgumentAsByteList(context, args[0]), flags);
dirs = Dir.push_glob(runtime, runtime.getCurrentDirectory(), globArgumentAsByteList(context, args[0]), flags);
} else {
dirs = dirGlobs(context, getCWD(runtime), ((RubyArray) tmp).toJavaArray(), flags);
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyFileStat.java
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ private void setup(String filename, boolean lstat) {
filename += "/";
}

file = JRubyFile.createResource(runtime.getPosix(), runtime.getCurrentDirectory(), filename);
file = JRubyFile.createResource(runtime, filename);
stat = lstat ? file.lstat() : file.stat();

if (stat == null) throw runtime.newErrnoFromInt(file.errno(), filename);
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyFileTest.java
Original file line number Diff line number Diff line change
@@ -466,7 +466,7 @@ private static RubyFileStat getRubyFileStat(ThreadContext context, IRubyObject f
RubyFileStat stat = null;
if (!(filename instanceof RubyFile)) {
RubyString path = get_path(context, filename);
FileResource file = JRubyFile.createResource(runtime.getPosix(), runtime.getCurrentDirectory(), path.getUnicodeValue());
FileResource file = JRubyFile.createResource(runtime, path.getUnicodeValue());
if (file.exists()) {
stat = runtime.newFileStat(file.absolutePath(), false);
}
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -514,7 +514,7 @@ protected RubyIO reopenIO(ThreadContext context, RubyIO nfile) {
}

private void checkReopenCloexecDup2(Ruby runtime, OpenFile orig, ChannelFD oldfd, ChannelFD newfd) {
OpenFile.cloexecDup2(new PosixShim(runtime.getPosix()), oldfd, newfd);
OpenFile.cloexecDup2(new PosixShim(runtime), oldfd, newfd);
}

// rb_io_binmode
@@ -1239,7 +1239,7 @@ private static ChannelFD cloexecOpen(Ruby runtime, Sysopen data)
// #elif defined O_NOINHERIT
// flags |= O_NOINHERIT;
// #endif
PosixShim shim = new PosixShim(runtime.getPosix());
PosixShim shim = new PosixShim(runtime);
ret = shim.open(runtime.getCurrentDirectory(), data.fname, ModeFlags.createModeFlags(data.oflags), data.perm);
if (ret == null) {
data.errno = shim.errno;
@@ -3967,7 +3967,7 @@ public static IRubyObject pipe19(ThreadContext context, IRubyObject klass, IRuby
}
}

PosixShim posix = new PosixShim(runtime.getPosix());
PosixShim posix = new PosixShim(runtime);
Channel[] fds = posix.pipe();
if (fds == null)
throw runtime.newErrnoFromErrno(posix.errno, "opening pipe");
23 changes: 15 additions & 8 deletions core/src/main/java/org/jruby/runtime/load/LibrarySearcher.java
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
import org.jruby.ast.executable.Script;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.load.LoadService.SuffixType;
import org.jruby.util.ClasspathResource;
import org.jruby.util.FileResource;
import org.jruby.util.JRubyFile;
import org.jruby.util.URLResource;
@@ -133,6 +132,7 @@ private FoundLibrary findResourceLibrary(String baseName, String suffix) {
return findFileResource(baseName, suffix);
}

// search the $LOAD_PATH
try {
for (IRubyObject loadPathEntry : loadService.loadPath.toJavaArray()) {
FoundLibrary library = findFileResourceWithLoadPath(baseName, suffix, getPath(loadPathEntry));
@@ -142,7 +142,19 @@ private FoundLibrary findResourceLibrary(String baseName, String suffix) {
t.printStackTrace();
}

return null;
// inside a classloader the path "." is the place where to find the jruby kernel
if (!runtime.getCurrentDirectory().startsWith(URLResource.URI_CLASSLOADER)) {

// ruby does not load a relative path unless the current working directory is in $LOAD_PATH
FoundLibrary library = findFileResourceWithLoadPath(baseName, suffix, ".");

// we did not find the file on the $LOAD_PATH but in current directory so we need to treat it
// as not found (the classloader search below will find it otherwise)
if (library != null) return null;
}

// load the jruby kernel and all resource added to $CLASSPATH
return findFileResourceWithLoadPath(baseName, suffix, URLResource.URI_CLASSLOADER);
}

// FIXME: to_path should not be called n times it should only be once and that means a cache which would
@@ -263,12 +275,7 @@ private void loadClass(Ruby runtime, InputStream is, boolean wrap) {
private void loadJar(Ruby runtime, boolean wrap) {
try {
URL url;
if (location.startsWith(ClasspathResource.CLASSPATH)){
// get URL directly from the classloader with its StreamHandler set
// by the classloader itself
url = ClasspathResource.getResourceURL(location);
}
else if (location.startsWith(URLResource.URI)){
if (location.startsWith(URLResource.URI)){
url = null;
runtime.getJRubyClassLoader().addURLNoIndex(URLResource.getResourceURL(runtime, location));
}
149 changes: 0 additions & 149 deletions core/src/main/java/org/jruby/util/ClasspathResource.java

This file was deleted.

Loading