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: fbc625589e20
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ce6a96583ada
Choose a head ref

Commits on Jul 8, 2015

  1. System.gc() is async, do not attempt to invoke it and retry sysopen a…

    …s it will always fail
    eam committed Jul 8, 2015
    Copy the full SHA
    3c87565 View commit details

Commits on Sep 2, 2015

  1. Copy the full SHA
    f3f3602 View commit details

Commits on Oct 5, 2015

  1. Copy the full SHA
    9ea4980 View commit details

Commits on Sep 3, 2016

  1. fix File.dirname with backslashes in unix

    Daniel Smith committed Sep 3, 2016
    Copy the full SHA
    aef4bad View commit details

Commits on Sep 24, 2016

  1. Merge remote-tracking branch 'upstream/master' into dirname-with-back…

    …slash-on-unix
    Daniel Smith committed Sep 24, 2016
    Copy the full SHA
    db355da View commit details
  2. Fix File.dirname on Windows (including UNC)

    Daniel Smith committed Sep 24, 2016
    Copy the full SHA
    f20829c View commit details

Commits on Oct 8, 2016

  1. Remove jruby deviation from File.split spec

    Daniel Smith committed Oct 8, 2016
    Copy the full SHA
    3eb2550 View commit details

Commits on Oct 10, 2016

  1. Copy the full SHA
    0badff8 View commit details

Commits on Oct 13, 2016

  1. Don't dup every element in Enumerator#drop

    In 06f0441 (JRUBY-6892) Enumerable#drop was changed to call #dup on every element that ended up in the result, but that might not work. Not all objects correctly implement #dup, or are even allocatable.
    
    #take was not changed, and looking at the differences between #take and #drop the only thing that stood out was that the signature of the #each call was different. Changing from Signature.NO_ARGUMENTS to Signature.ONE_REQUIRED make the issue that 06f0441 tried to fix go away.
    iconara committed Oct 13, 2016
    Copy the full SHA
    6996e2e View commit details

Commits on Oct 23, 2016

  1. use SEPARATOR and ALT_SEPARATOR in File.basename

    Daniel Smith committed Oct 23, 2016
    Copy the full SHA
    580a2e6 View commit details
  2. Fix basename with mixed slashes on windows

    Daniel Smith committed Oct 23, 2016
    Copy the full SHA
    5f2cced View commit details

Commits on Oct 26, 2016

  1. Copy the full SHA
    afc9939 View commit details
  2. Copy the full SHA
    9c49a58 View commit details

Commits on Oct 29, 2016

  1. Tag failures on Travis

    eregon committed Oct 29, 2016
    Copy the full SHA
    c67f1b4 View commit details

Commits on Oct 30, 2016

  1. Merge pull request #4250 from headius/methods_have_owners

    Prepend must set method's "defined class" to the new bottom.
    headius authored Oct 30, 2016
    Copy the full SHA
    f2b3a17 View commit details
  2. Copy the full SHA
    35f4547 View commit details
  3. Copy the full SHA
    06bd7f5 View commit details
  4. Merge pull request #4256 from jruby/revert-4159-sprintf_rounding

    Revert "Format initial string to specific precision, so rounding works."
    headius authored Oct 30, 2016
    Copy the full SHA
    a05168b View commit details

Commits on Oct 31, 2016

  1. Copy the full SHA
    9eee303 View commit details
  2. Copy the full SHA
    061764e View commit details
  3. Copy the full SHA
    5debf23 View commit details
  4. Merge pull request #4252 from headius/nil_init_for_temp_locals

    Also perform uninitialized check on temp locals.
    headius authored Oct 31, 2016
    Copy the full SHA
    b9b86fc View commit details
  5. No unsafe gets from closures; parent may not be jitted.

    This is a "fix" for #4235 in that it prevents closures from ever
    blindly reading closed-over variables that have not been
    initialized to nil. This may happen if the block jits independent
    of the method, in which case the method will continue to be run
    through null-checking interpreter logic, so the closure code
    cannot guarantee all values are non-null on first read.
    
    This is only a "fix" in quotes because it completely disables the
    fast path optimizaton for all non-method JIT.
    
    Note that I did add specialized "OrNil" paths to the generated
    DynamicScope subclasses, so that should at least inline to a field
    plus null check.
    headius committed Oct 31, 2016
    Copy the full SHA
    0e65638 View commit details

Commits on Nov 1, 2016

  1. Copy the full SHA
    e3cc519 View commit details

Commits on Nov 2, 2016

  1. System.gc() is async, do not attempt to invoke it and retry sysopen a…

    …s it will always fail
    eam authored and headius committed Nov 2, 2016
    Copy the full SHA
    0bc03a9 View commit details
  2. Merge pull request #2768 from eam/master

    System.gc() is async, do not attempt to invoke it and retry sysopen
    headius authored Nov 2, 2016
    Copy the full SHA
    466fee0 View commit details
  3. Make puts(str) zero-alloc.

    headius committed Nov 2, 2016
    Copy the full SHA
    223cbd5 View commit details
  4. Copy the full SHA
    49bd27d View commit details
  5. Copy the full SHA
    b0abc53 View commit details
  6. Copy the full SHA
    2501c07 View commit details
  7. Fix problems with lingering temp dirs.

    * Use system-level temp location from Dir.mktmpdir.
    * Use FileUtils.rm_rf to delete directory in teardown.
    
    See #1987.
    headius committed Nov 2, 2016
    Copy the full SHA
    d17628a View commit details
  8. Copy the full SHA
    fa6a300 View commit details
  9. Copy the full SHA
    07ad439 View commit details
  10. Fixes #3326. JRuby 9.0.1.0 vs. MRI 2.2.2 define_method inconsistency

    Problem was when we switched from arity to signature we added a new
    call and we passed the block arg passed to the symbol proc rather
    than the symbol proc itself.  Getting this to trigger did not really
    fit into any standard ruby behavior so I made a regression spec for
    it.  My guess is we only internally call the broken Java method if
    the block is set in an uncommon way (although I am not entirely
    sure what that is...but define_method will cause it to happen).
    enebo committed Nov 2, 2016
    Copy the full SHA
    643d442 View commit details

Commits on Nov 3, 2016

  1. Remove outdated maven settings file on Travis.

    The file on Travis refers to snapshot servers that are no longer online and may cause build problems.
    nirvdrum committed Nov 3, 2016
    1
    Copy the full SHA
    b64a5ee View commit details
  2. Copy the full SHA
    df2b042 View commit details
  3. Copy the full SHA
    73ea197 View commit details
  4. Merge pull request #3302 from stewartmatheson/updating_doco

    Updated doc for dumpThreads method in Runtime
    kares authored Nov 3, 2016
    Copy the full SHA
    56feb7b View commit details
  5. Merge pull request #4264 from etehtsea/fix-unnamed-socket-inspect

    Fix unnamed socket inspect
    enebo authored Nov 3, 2016
    Copy the full SHA
    af18037 View commit details
  6. Merge pull request #4248 from etehtsea/remove-pend-peeraddr

    UNIXSocket#peeraddr was fixed some time ago
    kares authored Nov 3, 2016
    Copy the full SHA
    38eaba9 View commit details
  7. Tag new specs for Truffle.

    headius committed Nov 3, 2016
    Copy the full SHA
    44564e5 View commit details
  8. Copy the full SHA
    6a436e9 View commit details

Commits on Nov 5, 2016

  1. Copy the full SHA
    20e80b8 View commit details
  2. do preffered JCE unrestriction on Java 9 - set "crypto.policy"

    ... also support Java 9 with JAVA_VERSION
    kares committed Nov 5, 2016
    Copy the full SHA
    c5ed103 View commit details
  3. Use prepended origin for visibility calculations.

    This fixes issues in the ActiveRecord suite with "load_records"
    could not be found. That method lived in ActiveRecord::Relation
    module. The root cause of this problem is still a bit unclear,
    but basically we end up with visibility check trying to compare
    the prepended version of Relation with a non-prepended version. I
    have been unable to reproduce it without Rails, though.
    
    Say the original Relation module is X. All methods in X know they
    live in X. When a new module Y gets prepended into X, X's methods
    must be relocated to a new PrependedModule entry added above the
    old X in the hierarchy, and their "implementationClass" used for
    superclass calculation gets set to the new PrependedModule.
    
    If we use the implementationClass to calculate visibility, we now
    have a problem; walking a hierarchy will only find the old X (now
    the faux prepend base of all X's), while implementationClass will
    point at the PrependedModule shim. By using the PrependedModule's
    origin here, we continue to do visibility comparisons against the
    original X object rather than against the prepended shim.
    headius committed Nov 5, 2016
    Copy the full SHA
    9eaa1bd View commit details

Commits on Nov 6, 2016

  1. Copy the full SHA
    3d8babd View commit details
  2. Merge pull request #4177 from jellymann/dirname-with-backslash-on-unix

    Fix issues with File.dirname
    enebo authored Nov 6, 2016
    Copy the full SHA
    bc7036a View commit details

Commits on Nov 7, 2016

  1. Copy the full SHA
    c7e1459 View commit details
  2. Copy the full SHA
    0b14a1a View commit details

Commits on Nov 8, 2016

  1. Copy the full SHA
    48cc9ba View commit details
Showing with 691 additions and 174 deletions.
  1. +1 −1 VERSION
  2. +1 −1 core/pom.xml
  3. +1 −1 core/src/main/java/org/jruby/AbstractRubyMethod.java
  4. +1 −0 core/src/main/java/org/jruby/PrependedModule.java
  5. +1 −1 core/src/main/java/org/jruby/Ruby.java
  6. +8 −4 core/src/main/java/org/jruby/RubyBasicObject.java
  7. +3 −6 core/src/main/java/org/jruby/RubyEnumerable.java
  8. +71 −24 core/src/main/java/org/jruby/RubyFile.java
  9. +17 −14 core/src/main/java/org/jruby/RubyIO.java
  10. +5 −5 core/src/main/java/org/jruby/RubyInstanceConfig.java
  11. +5 −8 core/src/main/java/org/jruby/RubyModule.java
  12. +6 −3 core/src/main/java/org/jruby/RubyProcess.java
  13. +1 −1 core/src/main/java/org/jruby/RubySymbol.java
  14. +20 −12 core/src/main/java/org/jruby/compiler/JITCompiler.java
  15. +6 −9 core/src/main/java/org/jruby/ext/thread/Mutex.java
  16. +24 −1 core/src/main/java/org/jruby/internal/runtime/methods/DynamicMethod.java
  17. +8 −2 core/src/main/java/org/jruby/ir/dataflow/analyses/DefinedVariableNode.java
  18. +30 −8 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
  19. +0 −1 core/src/main/java/org/jruby/lexer/yacc/StringTerm.java
  20. +11 −1 core/src/main/java/org/jruby/management/Runtime.java
  21. +48 −0 core/src/main/java/org/jruby/runtime/DynamicScope.java
  22. +7 −4 core/src/main/java/org/jruby/runtime/IRBlockBody.java
  23. +2 −2 core/src/main/java/org/jruby/runtime/backtrace/RubyStackTraceElement.java
  24. +43 −0 core/src/main/java/org/jruby/runtime/scope/DynamicScopeGenerator.java
  25. +24 −3 core/src/main/java/org/jruby/util/SecurityHelper.java
  26. +4 −5 core/src/main/java/org/jruby/util/Sprintf.java
  27. +1 −1 core/src/main/java/org/jruby/util/cli/Options.java
  28. +10 −0 core/src/main/java/org/jruby/util/io/EncodingUtils.java
  29. +1 −1 lib/pom.rb
  30. +3 −3 lib/pom.xml
  31. +3 −1 lib/ruby/stdlib/io/console.rb
  32. +3 −3 lib/ruby/stdlib/resolv.rb
  33. +3 −2 lib/ruby/stdlib/rubygems.rb
  34. +14 −13 lib/ruby/stdlib/rubygems/commands/query_command.rb
  35. +5 −1 lib/ruby/stdlib/rubygems/config_file.rb
  36. +7 −4 lib/ruby/stdlib/rubygems/dependency.rb
  37. +8 −3 lib/ruby/stdlib/rubygems/installer.rb
  38. +3 −0 lib/ruby/stdlib/rubygems/remote_fetcher.rb
  39. +46 −0 lib/ruby/stdlib/rubygems/request.rb
  40. +7 −0 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb
  41. +1 −1 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb
  42. +2 −2 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb
  43. +2 −2 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb
  44. +62 −0 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb
  45. +1 −1 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb
  46. +12 −1 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb
  47. +2 −2 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb
  48. +2 −2 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb
  49. +1 −1 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb
  50. +19 −5 lib/ruby/stdlib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb
  51. +1 −1 pom.xml
  52. +6 −0 spec/compiler/general_spec.rb
  53. +15 −0 spec/regression/GH-3326_symbol_proc_should_be_callable.rb
  54. +20 −0 spec/regression/GH-4218_enumerable_drop_should_not_change_identities.rb
  55. +14 −0 spec/ruby/core/file/basename_spec.rb
  56. +5 −0 spec/ruby/core/file/dirname_spec.rb
  57. +4 −0 spec/ruby/core/io/inspect_spec.rb
  58. +31 −0 spec/ruby/core/kernel/clone_spec.rb
  59. +4 −0 spec/ruby/core/regexp/source_spec.rb
  60. +17 −0 spec/ruby/library/socket/unixsocket/inspect_spec.rb
  61. +2 −0 spec/tags/ruby/core/marshal/dump_tags.txt
  62. +1 −0 spec/truffle/tags/core/regexp/source_tags.txt
  63. +1 −0 spec/truffle/tags/library/socket/unixsocket/inspect_tags.txt
  64. +0 −2 test/jruby/test_socket.rb
  65. +2 −2 test/jruby/test_tempfile_cleanup.rb
  66. +0 −1 test/mri/excludes/TestProcess.rb
  67. +1 −1 tool/truffle/merge.sh
  68. +1 −1 truffle/pom.xml
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.1.6.0-SNAPSHOT
9.1.7.0-SNAPSHOT
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ DO NOT MODIFIY - GENERATED CODE
<parent>
<groupId>org.jruby</groupId>
<artifactId>jruby-parent</artifactId>
<version>9.1.6.0-SNAPSHOT</version>
<version>9.1.7.0-SNAPSHOT</version>
</parent>
<artifactId>jruby-core</artifactId>
<name>JRuby Core</name>
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/AbstractRubyMethod.java
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ public String getMethodName() {

@JRubyMethod(name = "owner")
public IRubyObject owner(ThreadContext context) {
return implementationModule;
return method.getDefinedClass();
}

@JRubyMethod(name = "source_location")
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/PrependedModule.java
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ public PrependedModule(Ruby runtime, RubyClass superClass, RubyModule origin) {
for (Map.Entry<String, DynamicMethod> entry : methods.entrySet()) {
DynamicMethod method = entry.getValue();
method.setImplementationClass(this);
method.setDefinedClass(origin);
}
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1797,7 +1797,7 @@ private void initBuiltins() {
// we define the classes at boot because we need them
addBuiltinIfAllowed("thread.rb", Library.DUMMY);

if(RubyInstanceConfig.NATIVE_NET_PROTOCOL) {
if (RubyInstanceConfig.NATIVE_NET_PROTOCOL) {
addLazyBuiltin("net/protocol.rb", "net/protocol", "org.jruby.ext.net.protocol.NetProtocolBufferedIOLibrary");
}

12 changes: 8 additions & 4 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -959,7 +959,7 @@ public IRubyObject rbClone() {

// We're cloning ourselves, so we know the result should be a RubyObject
RubyBasicObject clone = (RubyBasicObject)getMetaClass().getRealClass().allocate();
clone.setMetaClass(getSingletonClassClone());
clone.setMetaClass(getSingletonClassCloneAndAttach(clone));
if (isTaint()) clone.setTaint(true);

initCopy(runtime.getCurrentContext(), clone, this, true);
@@ -968,21 +968,25 @@ public IRubyObject rbClone() {
return clone;
}

protected RubyClass getSingletonClassClone() {
return getSingletonClassCloneAndAttach(UNDEF);
}

/** rb_singleton_class_clone
*
* Will make sure that if the current objects class is a
* singleton, it will get cloned.
*
* @return either a real class, or a clone of the current singleton class
*/
protected RubyClass getSingletonClassClone() {
protected RubyClass getSingletonClassCloneAndAttach(IRubyObject attach) {
RubyClass klass = getMetaClass();

if (!klass.isSingleton()) {
return klass;
}

MetaClass clone = new MetaClass(getRuntime(), klass.getSuperClass(), ((MetaClass) klass).getAttached());
RubyClass clone = new MetaClass(getRuntime(), klass.getSuperClass(), attach);
clone.flags = flags;

if (this instanceof RubyClass) {
@@ -1176,7 +1180,7 @@ private RubyString inspectObj(final Ruby runtime, RubyString part) {

if (!first) encStrBufCat(runtime, part, INSPECT_COMMA);
encStrBufCat(runtime, part, INSPECT_SPACE);
encStrBufCat(runtime, part, entry.getKey().getBytes());
encStrBufCat(runtime, part, entry.getKey());
encStrBufCat(runtime, part, INSPECT_EQUALS);
encStrBufCat(runtime, part, sites(context).inspect.call(context, obj, obj).convertToString().getByteList());

9 changes: 3 additions & 6 deletions core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -355,16 +355,13 @@ public static IRubyObject drop(ThreadContext context, IRubyObject self, IRubyObj
final RubyArray result = runtime.newArray();

try {
each(context, self, new JavaInternalBlockBody(runtime, Signature.NO_ARGUMENTS) {
each(context, self, new JavaInternalBlockBody(runtime, Signature.ONE_REQUIRED) {
long i = len; // Atomic ?
public IRubyObject yield(ThreadContext context, IRubyObject[] args) {
IRubyObject packedArg = packEnumValues(context.runtime, args);
synchronized (result) {
if (i == 0) {
// While iterating over an RubyEnumerator, "arg"
// gets overwritten by the new value, leading to JRUBY-6892.
// So call .dup() whenever appropriate.
result.append(packedArg.isImmediate() ? packedArg : packedArg.dup());
IRubyObject packedArg = packEnumValues(context.runtime, args);
result.append(packedArg);
} else {
--i;
}
95 changes: 71 additions & 24 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -509,6 +509,15 @@ public IRubyObject inspect() {
@JRubyMethod(required = 1, optional = 1, meta = true)
public static IRubyObject basename(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
final String separator = runtime.getClass("File").getConstant("SEPARATOR").toString();
final char separatorChar = separator.charAt(0);
String altSeparator = null;
char altSeparatorChar = '\0';
final IRubyObject rbAltSeparator = runtime.getClass("File").getConstant("ALT_SEPARATOR");
if (rbAltSeparator != context.nil) {
altSeparator = rbAltSeparator.toString();
altSeparatorChar = altSeparator.charAt(0);
}

RubyString origString = StringSupport.checkEmbeddedNulls(runtime, get_path(context, args[0]));
Encoding origEncoding = origString.getEncoding();
@@ -542,16 +551,16 @@ public static IRubyObject basename(ThreadContext context, IRubyObject recv, IRub
}
}

while (name.length() > 1 && name.charAt(name.length() - 1) == '/') {
while (name.length() > 1 && (name.charAt(name.length() - 1) == separatorChar || (altSeparator != null && name.charAt(name.length() - 1) == altSeparatorChar))) {
name = name.substring(0, name.length() - 1);
}

// Paths which end in "/" or "\\" must be stripped off.
// Paths which end in File::SEPARATOR or File::ALT_SEPARATOR must be stripped off.
int slashCount = 0;
int length = name.length();
for (int i = length - 1; i >= 0; i--) {
char c = name.charAt(i);
if (c != '/' && c != '\\') {
if (c != separatorChar && (altSeparator == null || c != altSeparatorChar)) {
break;
}
slashCount++;
@@ -560,13 +569,12 @@ public static IRubyObject basename(ThreadContext context, IRubyObject recv, IRub
name = name.substring(0, name.length() - slashCount);
}

int index = name.lastIndexOf('/');
if (index == -1) {
// XXX actually only on windows...
index = name.lastIndexOf('\\');
int index = name.lastIndexOf(separatorChar);
if (altSeparator != null) {
index = Math.max(index, name.lastIndexOf(altSeparatorChar));
}

if (!name.equals("/") && index != -1) {
if (!(name.equals(separator) || (altSeparator != null && name.equals(altSeparator))) && index != -1) {
name = name.substring(index + 1);
}

@@ -651,32 +659,57 @@ public static IRubyObject dirname(ThreadContext context, IRubyObject recv, IRuby

static Pattern PROTOCOL_PATTERN = Pattern.compile(URI_PREFIX_STRING + ".*");
public static String dirname(ThreadContext context, String jfilename) {
String name = jfilename.replace('\\', '/');
final Ruby runtime = context.runtime;
final String separator = runtime.getClass("File").getConstant("SEPARATOR").toString();
final char separatorChar = separator.charAt(0);
String altSeparator = null;
char altSeparatorChar = '\0';
final IRubyObject rbAltSeparator = runtime.getClass("File").getConstant("ALT_SEPARATOR");
if (rbAltSeparator != context.nil) {
altSeparator = rbAltSeparator.toString();
altSeparatorChar = altSeparator.charAt(0);
}
String name = jfilename;
if (altSeparator != null) {
name = jfilename.replace(altSeparator, separator);
}
int minPathLength = 1;
boolean trimmedSlashes = false;

boolean startsWithSeparator = false;

if (!name.isEmpty()) {
startsWithSeparator = name.charAt(0) == separatorChar;
}

boolean startsWithUNCOnWindows = Platform.IS_WINDOWS && startsWith(name, separatorChar, separatorChar);

if (startsWithUNCOnWindows) {
minPathLength = 2;
}

boolean startsWithDriveLetterOnWindows = startsWithDriveLetterOnWindows(name);

if (startsWithDriveLetterOnWindows) {
minPathLength = 3;
}

// jar like paths
if (name.contains(".jar!/")) {
int start = name.indexOf("!/") + 1;
if (name.contains(".jar!" + separator)) {
int start = name.indexOf("!" + separator) + 1;
String path = dirname(context, name.substring(start));
if (path.equals(".") || path.equals("/")) path = "";
if (path.equals(".") || path.equals(separator)) path = "";
return name.substring(0, start) + path;
}
// address all the url like paths first
if (PROTOCOL_PATTERN.matcher(name).matches()) {
int start = name.indexOf(":/") + 2;
int start = name.indexOf(":" + separator) + 2;
String path = dirname(context, name.substring(start));
if (path.equals(".")) path = "";
return name.substring(0, start) + path;
}

while (name.length() > minPathLength && name.charAt(name.length() - 1) == '/') {
while (name.length() > minPathLength && name.charAt(name.length() - 1) == separatorChar) {
trimmedSlashes = true;
name = name.substring(0, name.length() - 1);
}
@@ -691,7 +724,7 @@ public static String dirname(ThreadContext context, String jfilename) {
}
} else {
//TODO deal with UNC names
int index = name.lastIndexOf('/');
int index = name.lastIndexOf(separator);

if (index == -1) {
if (startsWithDriveLetterOnWindows) {
@@ -701,7 +734,7 @@ public static String dirname(ThreadContext context, String jfilename) {
}
}
if (index == 0) {
return "/";
return jfilename.substring(0, 1);
}

if (startsWithDriveLetterOnWindows && index == 2) {
@@ -710,24 +743,38 @@ public static String dirname(ThreadContext context, String jfilename) {
index++;
}

if (startsWith(jfilename, '\\', '\\')) {
index = jfilename.length();
String[] split = jfilename.split(Pattern.quote("\\"));
if (split[ split.length - 1 ].indexOf('.') > -1) {
index = jfilename.lastIndexOf('\\');
if (startsWithUNCOnWindows) {
index = jfilename.length();
String[] split = name.split(Pattern.quote(separator));
int pathSectionCount = 0;
for (int i = 0; i < split.length; i++) {
if (!split[i].isEmpty()) {
pathSectionCount += 1;
}

}
if (pathSectionCount > 2) {
index = name.lastIndexOf(separator);
}
}

result = jfilename.substring(0, index);
}

// trim leading slashes
if (startsWithSeparator && result.length() > minPathLength) {
while (
result.length() > minPathLength &&
(result.charAt(minPathLength) == separatorChar ||
(altSeparator != null && result.charAt(minPathLength) == altSeparatorChar))
) {
result = result.substring(1, result.length());
}
}

char endChar;
// trim trailing slashes
while (result.length() > minPathLength) {
endChar = result.charAt(result.length() - 1);
if (endChar == '/' || endChar == '\\') {
if (endChar == separatorChar || (altSeparator != null && endChar == altSeparatorChar)) {
result = result.substring(0, result.length() - 1);
} else {
break;
31 changes: 17 additions & 14 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -1213,16 +1213,10 @@ protected static ChannelFD sysopen(Ruby runtime, String fname, int oflags, int p

fd = sysopenInternal(runtime, data);
if (fd == null) {
if (data.errno == Errno.EMFILE || data.errno == Errno.ENFILE) {
System.gc();
data.errno = null;
fd = sysopenInternal(runtime, data);
}
if (fd == null) {
if (data.errno != null) {
throw runtime.newErrnoFromErrno(data.errno, fname);
}
throw runtime.newSystemCallError(fname);
if (data.errno != null) {
throw runtime.newErrnoFromErrno(data.errno, fname.toString());
} else {
throw runtime.newSystemCallError(fname.toString());
}
}
return fd;
@@ -2525,22 +2519,30 @@ private static IRubyObject putsArray(ThreadContext context, IRubyObject maybeIO,

private static void putsSingle(ThreadContext context, Ruby runtime, IRubyObject maybeIO, IRubyObject arg, RubyString separator) {
ByteList line;
RubyString string;

if (arg.isNil()) {
line = getNilByteList(runtime);
string = null;
} else if (runtime.isInspecting(arg)) {
line = RECURSIVE_BYTELIST;
string = null;
} else if (arg instanceof RubyArray) {
inspectPuts(context, maybeIO, (RubyArray) arg);
return;
} else {
line = arg.asString().getByteList();
string = arg.asString();
line = string.getByteList();
}

write(context, maybeIO, line);
if (string != null) {
write(context, maybeIO, string);
} else {
write(context, maybeIO, line);
}

if (line.length() == 0 || !line.endsWith(separator.getByteList())) {
write(context, maybeIO, separator.getByteList());
write(context, maybeIO, separator);
}
}

@@ -2565,6 +2567,7 @@ public static IRubyObject write(ThreadContext context, IRubyObject maybeIO, IRub
return sites(context).write.call(context, maybeIO, maybeIO, str);
}

@JRubyMethod
@Override
public IRubyObject inspect() {
Ruby runtime = getRuntime();
@@ -2575,7 +2578,7 @@ public IRubyObject inspect() {
String path = openFile.getPath();
String status = "";

if (path == null) {
if (path == null || path == "") {
if (openFile.fd() == null) {
path = "";
status = "(closed)";
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
@@ -1761,7 +1761,7 @@ public boolean isTruffle() {
/**
* Enable use of the native Java version of the 'net/protocol' library.
*
* Set with the <tt>jruby.thread.pool.max</tt> system property.
* Set with the <tt>jruby.native.net.protocol</tt> system property.
*/
public static final boolean NATIVE_NET_PROTOCOL = Options.NATIVE_NET_PROTOCOL.load();

@@ -1900,11 +1900,11 @@ public boolean isTruffle() {
private static int initGlobalJavaVersion() {
final String specVersion = Options.BYTECODE_VERSION.load();
switch ( specVersion ) {
case "1.6" : return Opcodes.V1_6;
case "1.7" : return Opcodes.V1_7;
case "1.8" : return Opcodes.V1_8;
case "1.6" : return Opcodes.V1_6; // 50
case "1.7" : return Opcodes.V1_7; // 51
case "1.8" : case "8" : return Opcodes.V1_8; // 52
// NOTE: JDK 9 now returns "9" instead of "1.9"
case "1.9" : case "9" : return Opcodes.V1_8; // +1
case "1.9" : case "9" : return Opcodes.V1_8 + 1; // 53
default :
System.err.println("unsupported Java version \"" + specVersion + "\", defaulting to 1.7");
return Opcodes.V1_7;
Loading