Skip to content

Commit

Permalink
Showing 39 changed files with 144 additions and 246 deletions.
6 changes: 3 additions & 3 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -46,15 +46,15 @@
jar 'com.github.jnr:jnr-enxio:0.16', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-x86asm:1.0.2', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.17', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.43', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.44', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.9', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.1.7'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

jar 'org.jruby.joni:joni:2.1.13'
jar 'org.jruby.joni:joni:2.1.14'
jar 'org.jruby.extras:bytelist:1.0.15'
jar 'org.jruby.jcodings:jcodings:1.0.26'
jar 'org.jruby.jcodings:jcodings:1.0.27'
jar 'org.jruby:dirgra:0.3'

jar 'com.headius:invokebinder:1.11'
6 changes: 3 additions & 3 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -135,7 +135,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.43</version>
<version>3.0.44</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
@@ -173,7 +173,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
<version>2.1.13</version>
<version>2.1.14</version>
</dependency>
<dependency>
<groupId>org.jruby.extras</groupId>
@@ -183,7 +183,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>org.jruby.jcodings</groupId>
<artifactId>jcodings</artifactId>
<version>1.0.26</version>
<version>1.0.27</version>
</dependency>
<dependency>
<groupId>org.jruby</groupId>
1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/RubyEncoding.java
Original file line number Diff line number Diff line change
@@ -51,7 +51,6 @@
import org.jruby.runtime.encoding.EncodingService;
import org.jruby.runtime.opto.OptoFactory;
import org.jruby.util.ByteList;
import org.jruby.util.CodeRangeable;
import org.jruby.util.StringSupport;
import org.jruby.util.io.EncodingUtils;
import org.jruby.util.unsafe.UnsafeHolder;
35 changes: 24 additions & 11 deletions core/src/main/java/org/jruby/RubyHash.java
Original file line number Diff line number Diff line change
@@ -515,8 +515,6 @@ protected final void checkIterating() {
throw getRuntime().newRuntimeError("can't add a new key into hash during iteration");
}
}
// ------------------------------
public static long collisions = 0;

// put implementation

@@ -525,26 +523,32 @@ private final void internalPut(final IRubyObject key, final IRubyObject value) {
}

private final void internalPutSmall(final IRubyObject key, final IRubyObject value) {
internalPutSmall(key, value, true);
internalPutNoResize(key, value, true);
}

protected void internalPut(final IRubyObject key, final IRubyObject value, final boolean checkForExisting) {
checkResize();

internalPutSmall(key, value, checkForExisting);
internalPutNoResize(key, value, checkForExisting);
}

protected void internalPutSmall(final IRubyObject key, final IRubyObject value, final boolean checkForExisting) {
protected final IRubyObject internalJavaPut(final IRubyObject key, final IRubyObject value) {
checkResize();

return internalPutNoResize(key, value, true);
}

protected IRubyObject internalPutNoResize(final IRubyObject key, final IRubyObject value, final boolean checkForExisting) {
final int hash = hashValue(key);
final int i = bucketIndex(hash, table.length);

// if (table[i] != null) collisions++;

if (checkForExisting) {
for (RubyHashEntry entry = table[i]; entry != null; entry = entry.next) {
if (internalKeyExist(entry, hash, key)) {
IRubyObject existing = entry.value;
entry.value = value;
return;

return existing;
}
}
}
@@ -553,6 +557,9 @@ protected void internalPutSmall(final IRubyObject key, final IRubyObject value,

table[i] = new RubyHashEntry(hash, key, value, table[i], head);
size++;

// no existing entry
return null;
}

// get implementation
@@ -1040,7 +1047,7 @@ protected void op_asetSmallForString(Ruby runtime, RubyString key, IRubyObject v
} else {
checkIterating();
if (!key.isFrozen()) key = (RubyString)key.dupFrozen();
internalPutSmall(key, value, false);
internalPutNoResize(key, value, false);
}
}

@@ -2159,8 +2166,9 @@ public Object get(Object key) {

@Override
public Object put(Object key, Object value) {
internalPut(JavaUtil.convertJavaToUsableRubyObject(getRuntime(), key), JavaUtil.convertJavaToUsableRubyObject(getRuntime(), value));
return value;
Ruby runtime = getRuntime();
IRubyObject existing = internalJavaPut(JavaUtil.convertJavaToUsableRubyObject(runtime, key), JavaUtil.convertJavaToUsableRubyObject(runtime, value));
return existing == null ? null : existing.toJava(Object.class);
}

@Override
@@ -2600,4 +2608,9 @@ public IRubyObject default_value_get(ThreadContext context, IRubyObject[] args)
throw context.runtime.newArgumentError(args.length, 1);
}
}

@Deprecated
protected void internalPutSmall(final IRubyObject key, final IRubyObject value, final boolean checkForExisting) {
internalPutNoResize(key, value, checkForExisting);
}
}
33 changes: 20 additions & 13 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -2204,8 +2204,8 @@ public IRubyObject close_on_exec_set(ThreadContext context, IRubyObject arg) {
int fd = -1;

if (fptr == null || (fd = fptr.fd().realFileno) == -1
|| !posix.isNative()) {
runtime.getWarnings().warning("close_on_exec is not implemented for this stream type: " + fptr.fd().ch.getClass().getSimpleName());
|| !posix.isNative() || Platform.IS_WINDOWS ) {
runtime.getWarnings().warning("close_on_exec is not implemented on this platform for this stream type: " + fptr.fd().ch.getClass().getSimpleName());
return context.nil;
}

@@ -2408,12 +2408,12 @@ public void setBlocking(boolean blocking) {

@JRubyMethod(name = "fcntl")
public IRubyObject fcntl(ThreadContext context, IRubyObject cmd) {
return ctl(context.runtime, cmd, null);
return ctl(context, cmd, null);
}

@JRubyMethod(name = "fcntl")
public IRubyObject fcntl(ThreadContext context, IRubyObject cmd, IRubyObject arg) {
return ctl(context.runtime, cmd, arg);
return ctl(context, cmd, arg);
}

@JRubyMethod(name = "ioctl", required = 1, optional = 1)
@@ -2427,10 +2427,11 @@ public IRubyObject ioctl(ThreadContext context, IRubyObject[] args) {
arg = context.runtime.getNil();
}

return ctl(context.runtime, cmd, arg);
return ctl(context, cmd, arg);
}

private IRubyObject ctl(Ruby runtime, IRubyObject cmd, IRubyObject arg) {
private IRubyObject ctl(ThreadContext context, IRubyObject cmd, IRubyObject arg) {
Ruby runtime = context.runtime;
long realCmd = cmd.convertToInteger().getLongValue();
long nArg = 0;

@@ -2463,25 +2464,31 @@ private IRubyObject ctl(Ruby runtime, IRubyObject cmd, IRubyObject arg) {
// for mode changes which should persist across fork() boundaries. Since JVM has no fork
// this is not a problem for us.
if (realCmd == FcntlLibrary.FD_CLOEXEC) {
close_on_exec_set(runtime.getCurrentContext(), runtime.getTrue());
close_on_exec_set(context, runtime.getTrue());
} else if (realCmd == Fcntl.F_SETFD.intValue()) {
if (arg != null && (nArg & FcntlLibrary.FD_CLOEXEC) == FcntlLibrary.FD_CLOEXEC) {
close_on_exec_set(runtime.getCurrentContext(), arg);
close_on_exec_set(context, arg);
} else {
throw runtime.newNotImplementedError("F_SETFD only supports FD_CLOEXEC");
}
} else if (realCmd == Fcntl.F_GETFD.intValue()) {
return runtime.newFixnum(close_on_exec_p(runtime.getCurrentContext()).isTrue() ? FD_CLOEXEC : 0);
return runtime.newFixnum(close_on_exec_p(context).isTrue() ? FD_CLOEXEC : 0);
} else if (realCmd == Fcntl.F_SETFL.intValue()) {
if ((nArg & OpenFlags.O_NONBLOCK.intValue()) != 0) {
boolean block = (nArg & ModeFlags.NONBLOCK) != ModeFlags.NONBLOCK;
fptr.setBlocking(runtime, true);
} else {
fptr.setBlocking(runtime, false);
}

fptr.setBlocking(runtime, block);
if ((nArg & OpenFlags.O_CLOEXEC.intValue()) != 0) {
close_on_exec_set(context, context.tru);
} else {
throw runtime.newNotImplementedError("F_SETFL only supports O_NONBLOCK");
close_on_exec_set(context, context.fals);
}
} else if (realCmd == Fcntl.F_GETFL.intValue()) {
return fptr.isBlocking() ? RubyFixnum.zero(runtime) : RubyFixnum.newFixnum(runtime, ModeFlags.NONBLOCK);
return runtime.newFixnum(
(fptr.isBlocking() ? 0 : OpenFlags.O_NONBLOCK.intValue()) |
(close_on_exec_p(context).isTrue() ? FD_CLOEXEC : 0));
} else {
throw runtime.newNotImplementedError("JRuby only supports F_SETFL and F_GETFL with NONBLOCK for fcntl/ioctl");
}
7 changes: 1 addition & 6 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1212,11 +1212,6 @@ public final void addMethodAtBootTimeOnly(String name, DynamicMethod method) {
method.setImplementationClass(methodLocation);
}

// if method does not have a name already, set it
if (method.getName() == null) {
method.setName(name);
}

methodLocation.getMethodsForWrite().put(name, method);

getRuntime().addProfiledMethod(name, method);
@@ -2064,7 +2059,7 @@ private DynamicMethod createProcMethod(String name, Visibility visibility, RubyP
// a method definition.
block.getBody().getStaticScope().makeArgumentScope();

return new ProcMethod(this, proc, visibility);
return new ProcMethod(this, proc, visibility, name);
}

public IRubyObject name() {
16 changes: 9 additions & 7 deletions core/src/main/java/org/jruby/RubyNumeric.java
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@
import org.jruby.ast.util.ArgsUtil;
import org.jruby.common.RubyWarnings;
import org.jruby.exceptions.RaiseException;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallSite;
@@ -50,7 +49,6 @@
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CachingCallSite;
import org.jruby.util.ByteList;
import org.jruby.util.ConvertBytes;
import org.jruby.util.ConvertDouble;
@@ -62,7 +60,11 @@

import static org.jruby.RubyEnumerator.SizeFn;
import static org.jruby.RubyEnumerator.enumeratorizeWithSize;
import static org.jruby.util.Numeric.*;
import static org.jruby.util.Numeric.f_abs;
import static org.jruby.util.Numeric.f_arg;
import static org.jruby.util.Numeric.f_mul;
import static org.jruby.util.Numeric.f_negative_p;
import static org.jruby.util.Numeric.f_to_r;

/**
* Base class for all numerical types in ruby.
@@ -1236,21 +1238,21 @@ protected final IRubyObject op_num_equal(ThreadContext context, IRubyObject othe
return numFuncall(context, other, sites(context).op_equals, this);
}

/** num_numerator
/** numeric_numerator
*
*/
@JRubyMethod(name = "numerator")
public IRubyObject numerator(ThreadContext context) {
IRubyObject rational = RubyRational.newRationalConvert(context, this);
IRubyObject rational = f_to_r(context, this);
return sites(context).numerator.call(context, rational, rational);
}

/** num_denominator
/** numeric_denominator
*
*/
@JRubyMethod(name = "denominator")
public IRubyObject denominator(ThreadContext context) {
IRubyObject rational = RubyRational.newRationalConvert(context, this);
IRubyObject rational = f_to_r(context, this);
return sites(context).denominator.call(context, rational, rational);
}

17 changes: 9 additions & 8 deletions core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
@@ -227,8 +227,9 @@ public static RubyClass newInstance(IRubyObject recv, IRubyObject[] args, Block
final String memberName = args[i].asJavaString();
// if we are storing a name as well, index is one too high for values
final int index = (name == null && !nilName) ? i : i - 1;
newStruct.addMethod(memberName, new Accessor(newStruct, index));
newStruct.addMethod(memberName + '=', new Mutator(newStruct, index));
newStruct.addMethod(memberName, new Accessor(newStruct, memberName, index));
String nameAsgn = memberName + '=';
newStruct.addMethod(nameAsgn, new Mutator(newStruct, nameAsgn, index));
}

if (block.isGiven()) {
@@ -770,8 +771,8 @@ public IRubyObject initialize_copy(IRubyObject arg) {
private static class Accessor extends DynamicMethod {
private final int index;

public Accessor(RubyClass newStruct, int index) {
super(newStruct, Visibility.PUBLIC);
public Accessor(RubyClass newStruct, String name, int index) {
super(newStruct, Visibility.PUBLIC, name);
this.index = index;
}

@@ -788,15 +789,15 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz

@Override
public DynamicMethod dup() {
return new Accessor((RubyClass) getImplementationClass(), index);
return new Accessor((RubyClass) getImplementationClass(), name, index);
}
}

private static class Mutator extends DynamicMethod {
private final int index;

public Mutator(RubyClass newStruct, int index) {
super(newStruct, Visibility.PUBLIC);
public Mutator(RubyClass newStruct, String name, int index) {
super(newStruct, Visibility.PUBLIC, name);
this.index = index;
}

@@ -813,7 +814,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz

@Override
public DynamicMethod dup() {
return new Accessor((RubyClass) getImplementationClass(), index);
return new Mutator((RubyClass) getImplementationClass(), name, index);
}
}

1 change: 0 additions & 1 deletion core/src/main/java/org/jruby/ext/ffi/AbstractInvoker.java
Original file line number Diff line number Diff line change
@@ -80,7 +80,6 @@ protected AbstractInvoker(Ruby runtime, RubyClass klass, int arity, MemoryIO io)
public IRubyObject attach(ThreadContext context, IRubyObject obj, IRubyObject methodName) {

DynamicMethod m = createDynamicMethod(obj.getSingletonClass());
m.setName(methodName.asJavaString());
obj.getSingletonClass().addMethod(methodName.asJavaString(), m);
if (obj instanceof RubyModule) {
((RubyModule) obj).addMethod(methodName.asJavaString(), m);
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ext/ffi/Pointer.java
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ public boolean isKindOf(IRubyObject obj, RubyModule type) {
Pointer nullPointer = new Pointer(runtime, pointerClass, new NullMemoryIO(runtime));
pointerClass.setConstant("NULL", nullPointer);

runtime.getNilClass().addMethod("to_ptr", new NilToPointerMethod(runtime.getNilClass(), nullPointer));
runtime.getNilClass().addMethod("to_ptr", new NilToPointerMethod(runtime.getNilClass(), nullPointer, "to_ptr"));

return pointerClass;
}
@@ -197,8 +197,8 @@ private static final class NilToPointerMethod extends DynamicMethod {
private static final Arity ARITY = Arity.NO_ARGUMENTS;
private final Pointer nullPointer;

private NilToPointerMethod(RubyModule implementationClass, Pointer nullPointer) {
super(implementationClass, Visibility.PUBLIC);
private NilToPointerMethod(RubyModule implementationClass, Pointer nullPointer, String name) {
super(implementationClass, Visibility.PUBLIC, name);
this.nullPointer = nullPointer;
}

4 changes: 1 addition & 3 deletions core/src/main/java/org/jruby/ext/ffi/jffi/DefaultMethod.java
Original file line number Diff line number Diff line change
@@ -23,10 +23,9 @@ public class DefaultMethod extends DynamicMethod implements CacheableMethod {
protected final Arity arity;
protected final Function function;


public DefaultMethod(RubyModule implementationClass, Function function,
Signature signature, NativeInvoker defaultInvoker) {
super(implementationClass, Visibility.PUBLIC);
super(implementationClass, Visibility.PUBLIC, defaultInvoker.getName());
this.arity = Arity.fixed(signature.getParameterCount());
this.function = function;
this.defaultInvoker = defaultInvoker;
@@ -83,7 +82,6 @@ private synchronized NativeInvoker tryCompilation() {

NativeInvoker invoker = getJITHandle().compile(getImplementationClass(), function, signature, getName());
if (invoker != null) {
invoker.setName(getName());
compiledInvoker = invoker;
getImplementationClass().invalidateCacheDescendants();
return compiledInvoker;
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ abstract public class NativeInvoker extends DynamicMethod {


public NativeInvoker(RubyModule implementationClass, com.kenai.jffi.Function function, Signature signature) {
super(implementationClass, Visibility.PUBLIC);
super(implementationClass, Visibility.PUBLIC, "ffi"+function.getFunctionAddress());
this.arity = Arity.fixed(signature.getParameterCount());
this.function = function;
this.signature = signature;
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/ext/socket/RubySocket.java
Original file line number Diff line number Diff line change
@@ -646,6 +646,8 @@ static void handleSocketException(final Ruby runtime, final SocketException ex,
throw runtime.newErrnoEACCESError("Address already in use - " + caller + " for " + formatAddress(addr));
case "Address already in use" :
throw runtime.newErrnoEADDRINUSEError(caller + " for " + formatAddress(addr));
case "Protocol family unavailable" :
throw runtime.newErrnoEADDRNOTAVAILError(caller + " for " + formatAddress(addr));
}

// This is ugly, but what can we do, Java provides the same exception type
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public abstract class DelegatingDynamicMethod extends DynamicMethod {
protected final DynamicMethod delegate;

public DelegatingDynamicMethod(DynamicMethod delegate) {
super(delegate.getImplementationClass(), delegate.getVisibility());
super(delegate.getImplementationClass(), delegate.getVisibility(), delegate.getName());
this.delegate = delegate;
}

@@ -168,11 +168,6 @@ public String getName() {
return delegate.getName(); //To change body of overridden methods use File | Settings | File Templates.
}

@Override
public void setName(String name) {
delegate.setName(name); //To change body of overridden methods use File | Settings | File Templates.
}

@Override
public boolean isNotImplemented() {
return delegate.isNotImplemented(); //To change body of overridden methods use File | Settings | File Templates.
Original file line number Diff line number Diff line change
@@ -65,26 +65,13 @@ public abstract class DynamicMethod {
/** Flags for builtin, notimpl, etc */
protected byte flags;
/** The simple, base name this method was defined under. May be null.*/
protected String name;
protected final String name;
/** An arbitrarily-typed "method handle" for use by compilers and call sites */
protected Object handle;

private static final int BUILTIN_FLAG = 0x1;
private static final int NOTIMPL_FLAG = 0x2;

/**
* Base constructor for dynamic method handles.
*
* @param implementationClass The class to which this method will be
* immediately bound
* @param visibility The visibility assigned to this method
* pre/post invocation logic.
*/
protected DynamicMethod(RubyModule implementationClass, Visibility visibility) {
assert implementationClass != null;
init(implementationClass, visibility);
}

/**
* Base constructor for dynamic method handles with names.
*
@@ -94,15 +81,19 @@ protected DynamicMethod(RubyModule implementationClass, Visibility visibility) {
* @param name The simple name of this method
*/
protected DynamicMethod(RubyModule implementationClass, Visibility visibility, String name) {
this(implementationClass, visibility);
assert implementationClass != null;
assert name != null;
this.name = name;
init(implementationClass, visibility);
}

/**
* A no-arg constructor used only by the UndefinedMethod subclass and
* CompiledMethod handles. instanceof assertions make sure this is so.
*/
protected DynamicMethod() {
protected DynamicMethod(String name) {
this.visibility = (byte) Visibility.PUBLIC.ordinal();
this.name = name;
// assert (this instanceof UndefinedMethod ||
// this instanceof CompiledMethod ||
// this instanceof );
@@ -494,15 +485,6 @@ public String getName() {
return name;
}

/**
* Set the base name for this method.
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

/**
* Get the "handle" associated with this DynamicMethod.
*
@@ -571,4 +553,12 @@ public CallConfiguration getCallConfig() {
@Deprecated
public void setCallConfig(CallConfiguration callConfig) {
}

/**
* @deprecated Use {@link DynamicMethod#DynamicMethod(RubyModule, Visibility, String)}
*/
@Deprecated
protected DynamicMethod(RubyModule implementationClass, Visibility visibility) {
this(implementationClass, visibility, "(anonymous)");
}
}
Original file line number Diff line number Diff line change
@@ -76,31 +76,7 @@ public class HandleMethod extends DynamicMethod implements MethodArgs2, Cloneabl
public HandleMethod(
RubyModule implementationClass,
Visibility visibility,
long encodedSignature,
boolean builtin,
boolean notImplemented,
String parameterDesc,
final int min,
final int max,
final Callable<MethodHandle>... makers) {

super(implementationClass, visibility);
this.signature = Signature.decode(encodedSignature);
this.builtin = builtin;
this.notImplemented = notImplemented;
this.parameterDesc = parameterDesc;
this.min = min;
this.max = max;
this.maker0 = makers[0];
this.maker1 = makers[1];
this.maker2 = makers[2];
this.maker3 = makers[3];
this.maker4 = makers[4];
}

public HandleMethod(
RubyModule implementationClass,
Visibility visibility,
String name,
long encodedSignature,
boolean builtin,
boolean notImplemented,
@@ -113,7 +89,7 @@ public HandleMethod(
final Callable<MethodHandle> maker3,
final Callable<MethodHandle> maker4) {

super(implementationClass, visibility);
super(implementationClass, visibility, name);
this.signature = Signature.decode(encodedSignature);
this.builtin = builtin;
this.notImplemented = notImplemented;
@@ -284,7 +260,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule claz

@Override
public DynamicMethod dup() {
return new HandleMethod(implementationClass, getVisibility(), signature.encode(), builtin, notImplemented, parameterDesc, min, max, maker0, maker1, maker2, maker3, maker4);
return new HandleMethod(implementationClass, getVisibility(), name, signature.encode(), builtin, notImplemented, parameterDesc, min, max, maker0, maker1, maker2, maker3, maker4);
}

@Override
Original file line number Diff line number Diff line change
@@ -120,6 +120,7 @@ public DynamicMethod getAnnotatedMethod(final RubyModule implementationClass, fi
return new HandleMethod(
implementationClass,
desc1.anno.visibility(),
desc1.name,
(min == max) ?
org.jruby.runtime.Signature.from(min, 0, 0, 0, 0, org.jruby.runtime.Signature.Rest.NONE, -1).encode() :
org.jruby.runtime.Signature.OPTIONAL.encode(),
Original file line number Diff line number Diff line change
@@ -92,8 +92,6 @@ public JavaMethod(RubyModule implementationClass, Visibility visibility, String
super(implementationClass, visibility, name);
}

protected JavaMethod() {}

public void init(RubyModule implementationClass, Arity arity, Visibility visibility, StaticScope staticScope) {
this.staticScope = staticScope;
setArity(arity);
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public class MethodMethod extends DynamicMethod {
*/
public MethodMethod(RubyModule implementationClass, RubyUnboundMethod method, Visibility visibility) {
// FIXME: set up a CallConfiguration for this
super(implementationClass, visibility);
super(implementationClass, visibility, method.getMethodName());
this.method = method;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@ public class NullMethod extends DynamicMethod {
* Constructor for the one NullMethod instance.
*/
private NullMethod() {
super("null");
}

/**
Original file line number Diff line number Diff line change
@@ -53,9 +53,9 @@ public class ProcMethod extends DynamicMethod implements PositionAware, IRMethod
* Constructor for ProcMethod.
* @param visibility
*/
public ProcMethod(RubyModule implementationClass, RubyProc proc, Visibility visibility) {
public ProcMethod(RubyModule implementationClass, RubyProc proc, Visibility visibility, String name) {
// FIXME: set up a call configuration for this
super(implementationClass, visibility);
super(implementationClass, visibility, name);
this.proc = proc;
}

@@ -64,7 +64,7 @@ public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule klaz
}

public DynamicMethod dup() {
return new ProcMethod(getImplementationClass(), proc, getVisibility());
return new ProcMethod(getImplementationClass(), proc, getVisibility(), name);
}

// TODO: Push isSame up to DynamicMethod to simplify general equality
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ public class UndefinedMethod extends DynamicMethod {
* Constructor for the one UndefinedMethod instance.
*/
private UndefinedMethod() {
super("(undefined)");
}

/**
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ public class WrapperMethod extends DynamicMethod {
* @param visibility
*/
public WrapperMethod(RubyModule implementationClass, DynamicMethod method, Visibility visibility) {
super(implementationClass, visibility);
super(implementationClass, visibility, method.getName() );
this.method = method;
}

14 changes: 11 additions & 3 deletions core/src/main/java/org/jruby/java/proxies/MapJavaProxy.java
Original file line number Diff line number Diff line change
@@ -178,15 +178,23 @@ public RubyHash delete_ifInternal(final ThreadContext context, final Block block

@Override
public void internalPut(final IRubyObject key, final IRubyObject value, final boolean checkForExisting) {
internalPutSmall(key, value, checkForExisting);
internalPutNoResize(key, value, checkForExisting);
}

@Override
protected final void internalPutSmall(IRubyObject key, IRubyObject value, boolean checkForExisting) {
protected final IRubyObject internalPutNoResize(IRubyObject key, IRubyObject value, boolean checkForExisting) {
@SuppressWarnings("unchecked")
Ruby runtime = getRuntime();
final Map<Object, Object> map = mapDelegate();
map.put(key.toJava(Object.class), value.toJava(Object.class));
Object javaValue = value.toJava(Object.class);
Object existing = map.put(key.toJava(Object.class), javaValue);
setSize( map.size() );
if (existing != null) {
if (existing == javaValue) return value;
return JavaUtil.convertJavaToUsableRubyObject(runtime, existing);
}
// none existing
return null;
}

@Override
52 changes: 0 additions & 52 deletions core/src/main/java/org/jruby/java/util/BlankSlateWrapper.java

This file was deleted.

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
@@ -1092,7 +1092,7 @@ public final IRubyObject call(ThreadContext context, IRubyObject self, RubyModul
static final class ProcToInterface extends org.jruby.internal.runtime.methods.DynamicMethod {

ProcToInterface(final RubyClass singletonClass) {
super(singletonClass, PUBLIC);
super(singletonClass, PUBLIC, "call");
}

@Override // method_missing impl :
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/main/DripMain.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.Ruby;
import org.jruby.RubyInstanceConfig;
import org.jruby.util.cli.Options;

import java.io.File;
import java.io.FileInputStream;
@@ -30,6 +31,9 @@ public static void main(String[] args) throws IOException {
Ruby.clearGlobalRuntime();
File dripMain = new File(JRUBY_DRIP_PREBOOT_FILE);

// Disable native stdio when running under Drip (#4942)
Options.NATIVE_STDIO.force("false");

RubyInstanceConfig config = new RubyInstanceConfig();
ruby = Ruby.newInstance(config);

1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/runtime/Helpers.java
Original file line number Diff line number Diff line change
@@ -298,6 +298,7 @@ private static class MethodMissingMethod extends DynamicMethod {
private final Visibility lastVisibility;

public MethodMissingMethod(DynamicMethod delegate, Visibility lastVisibility, CallType lastCallStatus) {
super(delegate.getImplementationClass(), lastVisibility, delegate.getName());
this.delegate = delegate;
this.lastCallStatus = lastCallStatus;
this.lastVisibility = lastVisibility;
2 changes: 0 additions & 2 deletions core/src/main/java/org/jruby/runtime/backtrace/TraceType.java
Original file line number Diff line number Diff line change
@@ -157,8 +157,6 @@ public static TraceType traceTypeFor(String style) {
if (style.equalsIgnoreCase("raw")) return new TraceType(Gather.RAW, Format.JRUBY);
else if (style.equalsIgnoreCase("ruby_framed")) return new TraceType(Gather.NORMAL, Format.JRUBY);
else if (style.equalsIgnoreCase("normal")) return new TraceType(Gather.NORMAL, Format.JRUBY);
// deprecated, just uses jruby format now
else if (style.equalsIgnoreCase("rubinius")) return new TraceType(Gather.NORMAL, Format.JRUBY);
else if (style.equalsIgnoreCase("full")) return new TraceType(Gather.FULL, Format.JRUBY);
else if (style.equalsIgnoreCase("mri")) return new TraceType(Gather.NORMAL, Format.MRI);
else return new TraceType(Gather.NORMAL, Format.JRUBY);
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/IOChannel.java
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ protected int write(CallSite write, ByteBuffer src) throws IOException {
ByteList buffer;

if (src.hasArray()) {
buffer = new ByteList(src.array(), src.position(), src.remaining(), false);
buffer = new ByteList(src.array(), src.position(), src.remaining(), true);
} else {
buffer = new ByteList(src.remaining());
buffer.append(src, src.remaining());
17 changes: 17 additions & 0 deletions core/src/test/java/org/jruby/test/TestRubyHash.java
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@
import org.jruby.RubyHash;
import org.jruby.RubySymbol;
import org.jruby.exceptions.RaiseException;
import org.jruby.runtime.builtin.IRubyObject;

/**
* @author chadfowler
@@ -194,4 +195,20 @@ public void testGet() {
public void testDoubleQuotedUtf8HashKey() throws Exception {
assertEquals("UTF-8", eval("# encoding: utf-8\n h = { \"Ãa1\": true }\n puts h.keys.first.encoding"));
}

public void testPutExisting() {
Ruby ruby = Ruby.newInstance();
IRubyObject hash = ruby.evalScriptlet("{ \"Jane Doe\" => 10, \"Jim Doe\" => 6 }");
assertTrue(RubyHash.class.isInstance(hash));
RubyHash rubyHash = (RubyHash) hash;
assertEquals(10L, rubyHash.put("Jane Doe", 42));
}

public void testPutNotExisting() {
Ruby ruby = Ruby.newInstance();
IRubyObject hash = ruby.evalScriptlet("{ \"Jim Doe\" => 6 }");
assertTrue(RubyHash.class.isInstance(hash));
RubyHash rubyHash = (RubyHash) hash;
assertEquals(null, rubyHash.put("Jane Doe", 42));
}
}
5 changes: 0 additions & 5 deletions lib/ruby/stdlib/jruby/vm.rb
Original file line number Diff line number Diff line change
@@ -189,9 +189,4 @@ def initialize()
CURRENT = MainVM.new
MAP ||= HashMap.new
MAP[VM_ID] = CURRENT
end

module Rubinius
VM = JRuby::VM
VM_ID = JRuby::VM_ID
end
2 changes: 1 addition & 1 deletion lib/ruby/stdlib/resolv.rb
Original file line number Diff line number Diff line change
@@ -772,7 +772,7 @@ def sender(msg, data, host, port=Port)
sock = @socks_hash[host.index(':') ? "::" : "0.0.0.0"]
return nil if !sock
service = [IPAddr.new(host), port]
id = DNS.allocate_request_id(host, port)
id = DNS.allocate_request_id(service[0], service[1])
request = msg.encode
request[0,2] = [id].pack('n')
return @senders[[service, id]] =
2 changes: 1 addition & 1 deletion spec/tags/ruby/core/regexp/union_tags.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fails:Regexp.union returns a Regexp with the encoding of multiple non-conflicting ASCII-incompatible String arguments
critical(hangs):Regexp.union returns a Regexp with the encoding of multiple non-conflicting ASCII-incompatible String arguments
4 changes: 3 additions & 1 deletion test/mri/excludes/Rational_Test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
exclude :test_coerce2, "needs investigation"
exclude :test_conv, "needs investigation"
exclude :test_marshal, "needs investigation"
<<<<<<< HEAD
exclude :test_power_overflow, "consumes much time and memory on JVM"
=======
>>>>>>> jruby-9.1
exclude :test_ratsub, "needs investigation"
3 changes: 0 additions & 3 deletions test/mri/excludes/TestRegexp.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
exclude :test_cclass_X, "Unicode 9.0 update in 2.4 (#4731)"
exclude :test_char_class, "needs investigation"
exclude :test_dup_warn, "needs investigation"
exclude :test_initialize, "needs investigation"
exclude :test_invalid_escape_error, "needs investigation"
exclude :test_invalid_fragment, "needs investigation"
2 changes: 1 addition & 1 deletion test/mri/excludes/TestString.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude :test_rpartition, "needs investigation"
exclude :test_casecmp?, "missing 2.4 case-folding logic (#4731)"
exclude :test_crypt, "does not raise as expected"
exclude :test_rpartition, "needs investigation"
exclude :test_setter, "does not raise as expected"
1 change: 0 additions & 1 deletion test/mri/excludes/TestSymbol.rb
Original file line number Diff line number Diff line change
@@ -7,4 +7,3 @@
exclude :test_to_proc_no_method, "works but 'assert_separately failed\npid 28416 exit 143' on CI, moved to jruby/test_symbol.rb"
exclude :test_to_proc_yield, "works but 'Timeout::Error: execution of assert_ruby_status expired\npid 28480 exit 143' on CI, moved to jruby/test_symbol.rb"
exclude :test_symbol_encoding, "needs investigation"
#exclude :test_symbol_fstr_leak, "works but Test::Unit's assert_no_memory_leak spawns a sub-Ruby"

0 comments on commit f8ac719

Please sign in to comment.