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

Commits on Feb 17, 2016

  1. Copy the full SHA
    5cbe594 View commit details
  2. Copy the full SHA
    ff57fa5 View commit details
  3. Copy the full SHA
    cc09307 View commit details
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/RubyConverter.java
Original file line number Diff line number Diff line change
@@ -351,10 +351,11 @@ public IRubyObject primitive_convert(ThreadContext context, IRubyObject[] args)
@JRubyMethod
public IRubyObject convert(ThreadContext context, IRubyObject srcBuffer) {
Ruby runtime = context.runtime;
RubyString orig = srcBuffer.convertToString();
IRubyObject dest;

IRubyObject[] newArgs = {
srcBuffer.convertToString().dup(),
orig.dup(),
dest = runtime.newString(),
context.nil,
context.nil,
@@ -382,6 +383,8 @@ public IRubyObject convert(ThreadContext context, IRubyObject srcBuffer) {
}
}

dest.infectBy(orig);

return dest;
}

13 changes: 10 additions & 3 deletions core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
Original file line number Diff line number Diff line change
@@ -674,11 +674,18 @@ public static IRubyObject isDefinedConstantOrMethod(ThreadContext context, IRuby
public static IRubyObject isDefinedMethod(ThreadContext context, IRubyObject receiver, String name, boolean checkIfPublic) {
DynamicMethod method = receiver.getMetaClass().searchMethod(name);

// If we find the method we optionally check if it is public before returning "method".
if (!method.isUndefined() && (!checkIfPublic || method.getVisibility() == Visibility.PUBLIC)) {
return context.runtime.getDefinedMessage(DefinedMessage.METHOD);
boolean defined = !method.isUndefined();

if (defined) {
// If we find the method we optionally check if it is public before returning "method".
defined = !checkIfPublic || method.getVisibility() == Visibility.PUBLIC;
} else {
// If we did not find the method, check respond_to_missing?
defined = receiver.respondsToMissing(name, checkIfPublic);
}

if (defined) return context.runtime.getDefinedMessage(DefinedMessage.METHOD);

return context.nil;
}

26 changes: 21 additions & 5 deletions core/src/main/java/org/jruby/runtime/marshal/UnmarshalStream.java
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
import org.jruby.RubyArray;
import org.jruby.RubyBignum;
import org.jruby.RubyClass;
import org.jruby.RubyEncoding;
import org.jruby.RubyFixnum;
import org.jruby.RubyFloat;
import org.jruby.RubyHash;
@@ -135,7 +136,12 @@ private IRubyObject unmarshalObject(MarshalState state, boolean callProc) throws
result = unmarshalObjectDirectly(type, state, callProc);
}

if (!(result instanceof RubyNumeric)) result.setTaint(taint);
if (!(
result instanceof RubyNumeric ||
result instanceof RubyEncoding
)) {
result.setTaint(taint);
}

return result;
}
@@ -427,12 +433,22 @@ private IRubyObject userUnmarshal(MarshalState state) throws IOException {
ByteList marshaled = unmarshalString();
RubyClass classInstance = findClass(className);
RubyString data = RubyString.newString(runtime, marshaled);
if (state.isIvarWaiting()) {
defaultVariablesUnmarshal(data);
state.setIvarWaiting(false);
IRubyObject unmarshaled;

// Special case Encoding so they are singletons
// See https://bugs.ruby-lang.org/issues/11760
if (classInstance == runtime.getEncoding()) {
unmarshaled = RubyEncoding.find(runtime.getCurrentContext(), classInstance, data);
} else {
if (state.isIvarWaiting()) {
defaultVariablesUnmarshal(data);
state.setIvarWaiting(false);
}
unmarshaled = classInstance.smartLoadOldUser(data);
}
IRubyObject unmarshaled = classInstance.smartLoadOldUser(data);

registerLinkTarget(unmarshaled);

return unmarshaled;
}