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

Commits on Feb 19, 2016

  1. Raise error if stopping sole thread.

    Fixes MRI TestThread#test_stop.
    headius committed Feb 19, 2016
    Copy the full SHA
    e4e2242 View commit details
  2. Better handling of default hash values in sprintf.

    Fixes MRI TestSprintf#test_named_with_nil.
    headius committed Feb 19, 2016
    Copy the full SHA
    42ce617 View commit details
  3. Minor formatting.

    headius committed Feb 19, 2016
    Copy the full SHA
    c250d7d View commit details
  4. Fixes for Signal to fix MRI TestSignal#test_signame_delivered.

    * Pass signal number to handler.
    * #signame should return name without SIG prefix.
    headius committed Feb 19, 2016
    Copy the full SHA
    e66a315 View commit details
  5. Copy the full SHA
    fab6dd7 View commit details
  6. Copy the full SHA
    14ae9cd View commit details
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -233,15 +233,15 @@ public static final RubyHash newHash(Ruby runtime, Map valueMap, IRubyObject def

private RubyHash(Ruby runtime, RubyClass klass, RubyHash other) {
super(runtime, klass);
this.ifNone = runtime.getNil();
this.ifNone = UNDEF;
threshold = INITIAL_THRESHOLD;
table = other.internalCopyTable(head);
size = other.size;
}

public RubyHash(Ruby runtime, RubyClass klass) {
super(runtime, klass);
this.ifNone = runtime.getNil();
this.ifNone = UNDEF;
allocFirst();
}

@@ -702,15 +702,15 @@ public IRubyObject default_value_get(ThreadContext context) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
return context.nil;
}
return ifNone;
return ifNone == UNDEF ? context.nil : ifNone;
}

@JRubyMethod(name = "default")
public IRubyObject default_value_get(ThreadContext context, IRubyObject arg) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
return Helpers.invoke(context, ifNone, "call", this, arg);
}
return ifNone;
return ifNone == UNDEF ? context.nil : ifNone;
}

/** rb_hash_set_default
@@ -1679,7 +1679,7 @@ public IRubyObject shift(ThreadContext context) {
if ((flags & PROCDEFAULT_HASH_F) != 0) {
return this.callMethod(context, "default", context.nil);
}
return ifNone;
return ifNone == UNDEF ? context.nil : ifNone;
}

public final boolean fastDelete(IRubyObject key) {
@@ -2116,7 +2116,7 @@ public void visit(IRubyObject key, IRubyObject value) {
throw (IOException)e.getCause();
}

if (!hash.ifNone.isNil()) output.dumpObject(hash.ifNone);
if (hash.ifNone != UNDEF) output.dumpObject(hash.ifNone);
}

public static RubyHash unmarshalFrom(UnmarshalStream input, boolean defaultValue) throws IOException {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubySignal.java
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ public static IRubyObject signame(ThreadContext context, final IRubyObject recv,
public static String signo2signm(long no) {
for (Signal s : Signal.values()) {
if (s.intValue() == no) {
return s.name();
return s.name().substring(3);
}
}
return null;
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
@@ -1121,6 +1121,10 @@ public RubyArray keys() {
public static IRubyObject stop(ThreadContext context, IRubyObject receiver) {
RubyThread rubyThread = context.getThread();

if (context.runtime.getThreadService().getActiveRubyThreads().length == 1) {
throw context.runtime.newThreadError("stopping only thread\n\tnote: use sleep to stop forever");
}

synchronized (rubyThread) {
rubyThread.pollThreadEvents(context);
try {
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@
import org.jcodings.specific.UTF8Encoding;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyBasicObject;
import org.jruby.RubyBignum;
import org.jruby.RubyBoolean;
import org.jruby.RubyClass;
@@ -268,9 +269,9 @@ private void writeObjectData(IRubyObject value) throws IOException {
case HASH: {
RubyHash hash = (RubyHash)value;

if(hash.getIfNone().isNil()){
if(hash.getIfNone() == RubyBasicObject.UNDEF){
write('{');
}else if (hash.hasDefaultProc()) {
} else if (hash.hasDefaultProc()) {
throw hash.getRuntime().newTypeError("can't dump hash with default proc");
} else {
write('}');
15 changes: 11 additions & 4 deletions core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
import org.jcodings.specific.UTF8Encoding;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyBasicObject;
import org.jruby.RubyBignum;
import org.jruby.RubyFixnum;
import org.jruby.RubyFloat;
@@ -132,7 +133,7 @@ private static final class Args {
// temporary hack to handle non-Ruby values
// will come up with better solution shortly
Args(Ruby runtime, long value) {
this(RubyFixnum.newFixnum(runtime,value));
this(RubyFixnum.newFixnum(runtime, value));
}

void raiseArgumentError(String message) {
@@ -160,9 +161,15 @@ IRubyObject next(ByteList name) {
IRubyObject object = rubyHash.fastARef(nameSym);

// if not found, try dispatching to pick up default hash value
if (object == null) object = rubyHash.callMethod(runtime.getCurrentContext(), "[]", nameSym);

if (object.isNil()) raiseKeyError("key<" + name + "> not found");
// MRI: spliced together bits from rb_hash_default_value
if (object == null) {
object = rubyHash.getIfNone();
if (object == RubyBasicObject.UNDEF) {
raiseKeyError("key<" + name + "> not found");
} else if (rubyHash.hasDefaultProc()) {
object = object.callMethod(runtime.getCurrentContext(), "call", nameSym);
}
}
return object;
} else if (rubyHash != null) {
raiseArgumentError("positional args mixed with named args");
6 changes: 4 additions & 2 deletions core/src/main/java/org/jruby/util/SunSignalFacade.java
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
package org.jruby.util;

import org.jruby.Ruby;
import org.jruby.RubyFixnum;
import org.jruby.RubyModule;
import org.jruby.RubyProc;

@@ -84,10 +85,11 @@ public void handle(Signal signal) {
ThreadContext context = runtime.getCurrentContext();
IRubyObject oldExc = runtime.getGlobalVariables().get("$!"); // Save $!
try {
RubyFixnum signum = runtime.newFixnum(signal.getNumber());
if (block != null) {
block.callMethod(context, "call");
block.callMethod(context, "call", signum);
} else {
blockCallback.call(context, new IRubyObject[0], Block.NULL_BLOCK);
blockCallback.call(context, new IRubyObject[] {signum}, Block.NULL_BLOCK);
}
} catch(RaiseException e) {
try {
3 changes: 3 additions & 0 deletions test/mri/excludes/TestRequire.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
exclude :test_define_class, "an MRI inconsistency - NameError when class BasicSocket already defined!"
exclude :test_frozen_loaded_features, "error message does not match"
exclude :test_load_ospath, "we lose encoding on the way into load, can't preserve for LoadError message"
exclude :test_load2, "needs investigation"
exclude :test_loading_fifo_threading_raise, "we do not use IO to read files and so will not show as stopped while loading"
exclude :test_loading_fifo_threading_success, "we do not use IO to read files and so will not show as stopped while loading"
exclude :test_race_exception, "needs investigation"
exclude :test_require_changed_home, "needs investigation"
exclude :test_require_nonascii, "needs investigation"