Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Dec 14, 2016
2 parents 8fbabef + 48f1ac2 commit faf00ed
Show file tree
Hide file tree
Showing 134 changed files with 601 additions and 14,139 deletions.
8 changes: 4 additions & 4 deletions core/pom.rb
Expand Up @@ -46,12 +46,12 @@

# exclude jnr-ffi to avoid problems with shading and relocation of the asm packages
jar 'com.github.jnr:jnr-netdb:1.1.6', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.14-SNAPSHOT', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-enxio:0.14', :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.14', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.32', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-unixsocket:0.15', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-posix:3.0.33', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-constants:0.9.6', :exclusions => ['com.github.jnr:jnr-ffi']
jar 'com.github.jnr:jnr-ffi:2.1.1'
jar 'com.github.jnr:jnr-ffi:2.1.2'
jar 'com.github.jnr:jffi:${jffi.version}'
jar 'com.github.jnr:jffi:${jffi.version}:native'

Expand Down
8 changes: 4 additions & 4 deletions core/pom.xml
Expand Up @@ -104,7 +104,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-enxio</artifactId>
<version>0.14-SNAPSHOT</version>
<version>0.14</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -126,7 +126,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-unixsocket</artifactId>
<version>0.14</version>
<version>0.15</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -137,7 +137,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-posix</artifactId>
<version>3.0.32</version>
<version>3.0.33</version>
<exclusions>
<exclusion>
<artifactId>jnr-ffi</artifactId>
Expand All @@ -159,7 +159,7 @@ DO NOT MODIFIY - GENERATED CODE
<dependency>
<groupId>com.github.jnr</groupId>
<artifactId>jnr-ffi</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.github.jnr</groupId>
Expand Down
9 changes: 2 additions & 7 deletions core/src/main/java/org/jruby/NativeException.java
Expand Up @@ -167,18 +167,13 @@ public void trimStackTrace(Member target) {
}

@Override
@SuppressWarnings("deprecation")
public final IRubyObject getMessage() {
if (message == null) {
if (messageAsJavaString == null) {
message = getRuntime().getNil();
} else {
message = getRuntime().newString(messageAsJavaString);
return message = getRuntime().getNil();
}

return message;
return message = getRuntime().newString(messageAsJavaString);
}

return message;
}

Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/Ruby.java
Expand Up @@ -1721,6 +1721,8 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
runtime.getLoadService().require("jruby/win32ole/stub");
}
});

addLazyBuiltin("cgi/escape.jar", "cgi/escape", "org.jruby.ext.cgi.escape.CGIEscape");
}

private void initRubyKernel() {
Expand Down
13 changes: 10 additions & 3 deletions core/src/main/java/org/jruby/RubyArray.java
Expand Up @@ -1726,7 +1726,7 @@ public IRubyObject last(IRubyObject arg0) {
public IRubyObject each(ThreadContext context, Block block) {
if (!block.isGiven()) return enumeratorizeWithSize(context, this, "each", enumLengthFn());

for (int i = 0; i < realLength; i++) {
for (int i = 0; i < size(); i++) {
// do not coarsen the "safe" catch, since it will misinterpret AIOOBE from the yielded code.
// See JRUBY-5434
block.yield(context, eltOk(i));
Expand Down Expand Up @@ -2188,6 +2188,7 @@ private long fillLen(long beg, IRubyObject arg) {
}

protected IRubyObject fillCommon(ThreadContext context, int beg, long len, IRubyObject item) {
unpack();
modify();

// See [ruby-core:17483]
Expand All @@ -2214,6 +2215,7 @@ protected IRubyObject fillCommon(ThreadContext context, int beg, long len, IRuby
}

protected IRubyObject fillCommon(ThreadContext context, int beg, long len, Block block) {
unpack();
modify();

// See [ruby-core:17483]
Expand Down Expand Up @@ -2461,15 +2463,18 @@ public IRubyObject collect(ThreadContext context, Block block) {

IRubyObject[] arr = new IRubyObject[realLength];

int i;
return collectFrom(context, arr, 0, block);
}

protected IRubyObject collectFrom(ThreadContext context, IRubyObject[] arr, int i, Block block) {
for (i = 0; i < realLength; i++) {
// Do not coarsen the "safe" check, since it will misinterpret AIOOBE from the yield
// See JRUBY-5434
arr[i] = block.yield(context, eltOk(i));
}

// use iteration count as new size in case something was deleted along the way
return newArrayMayCopy(runtime, arr, 0, i);
return newArrayMayCopy(context.runtime, arr, 0, i);
}

@JRubyMethod(name = {"collect"})
Expand Down Expand Up @@ -3500,6 +3505,8 @@ protected static int compareOthers(ThreadContext context, IRubyObject o1, IRubyO
}

protected IRubyObject sortInternal(final ThreadContext context, final Block block) {
// block code can modify, so we need to iterate
unpack();
IRubyObject[] newValues = new IRubyObject[realLength];
int length = realLength;

Expand Down
12 changes: 5 additions & 7 deletions core/src/main/java/org/jruby/RubyException.java
Expand Up @@ -134,7 +134,6 @@ public RubyException exception(IRubyObject[] args) {
}

@JRubyMethod(name = "to_s")
@SuppressWarnings("deprecation")
public IRubyObject to_s(ThreadContext context) {
final IRubyObject msg = getMessage();
if ( ! msg.isNil() ) return msg.asString();
Expand Down Expand Up @@ -273,7 +272,7 @@ public void initBacktrace() {
}

@Override
@SuppressWarnings("deprecation")
@SuppressWarnings("deprecated")
public void copySpecialInstanceVariables(IRubyObject clone) {
RubyException exception = (RubyException)clone;
exception.backtraceData = backtraceData;
Expand Down Expand Up @@ -393,7 +392,7 @@ public static IRubyObject newException(ThreadContext context, RubyClass exceptio
/**
* @return error message if provided or nil
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("deprecated")
public IRubyObject getMessage() {
return message == null ? getRuntime().getNil() : message;
}
Expand All @@ -402,7 +401,7 @@ public IRubyObject getMessage() {
* Set the message for this NameError.
* @param message the message
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("deprecated")
public void setMessage(IRubyObject message) {
this.message = message;
}
Expand All @@ -414,9 +413,8 @@ public String getMessageAsJavaString() {

private BacktraceData backtraceData;
private IRubyObject backtrace;
@Deprecated
public IRubyObject message;
protected IRubyObject cause;
IRubyObject message;
IRubyObject cause;

public static final int TRACE_HEAD = 8;
public static final int TRACE_TAIL = 4;
Expand Down
11 changes: 4 additions & 7 deletions core/src/main/java/org/jruby/RubyKernel.java
Expand Up @@ -621,7 +621,7 @@ public static IRubyObject respond_to_missing_p(ThreadContext context, IRubyObjec

/** Returns value of $_.
*
* @throws TypeError if $_ is not a String or nil.
* @throws RaiseException TypeError if $_ is not a String or nil.
* @return value of $_ as String.
*/
private static RubyString getLastlineString(ThreadContext context, Ruby runtime) {
Expand Down Expand Up @@ -1174,15 +1174,12 @@ private static RaiseException uncaughtThrow(Ruby runtime, IRubyObject tag, IRuby
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject message) {
final Ruby runtime = context.runtime;

if (runtime.warningsEnabled()) {
IRubyObject out = runtime.getGlobalVariables().get("$stderr");
sites(context).write.call(context, out, out, message);
sites(context).write.call(context, out, out, runtime.getGlobalVariables().getDefaultSeparator());
}
if (runtime.warningsEnabled()) RubyIO.puts1(context, runtime.getGlobalVariables().get("$stderr"), message);

return context.nil;
}

@JRubyMethod(module = true, required = 1, rest = true, visibility = PRIVATE)
@JRubyMethod(module = true, rest = true, visibility = PRIVATE)
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject... messages) {
for (IRubyObject message : messages) warn(context, recv, message);
return context.nil;
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/RubyNameError.java
Expand Up @@ -218,8 +218,8 @@ static RubyException newNameError(IRubyObject recv, IRubyObject message, IRubyOb
@JRubyMethod(rest = true, visibility = Visibility.PRIVATE)
@Override
public IRubyObject initialize(IRubyObject[] args, Block block) {
if ( args.length > 0 ) this.setMessage(args[0]);
if (getMessage() instanceof RubyNameErrorMessage) this.receiver = ((RubyNameErrorMessage) getMessage()).object;
if ( args.length > 0 ) this.message = args[0];
if (message instanceof RubyNameErrorMessage) this.receiver = ((RubyNameErrorMessage) message).object;
if ( args.length > 1 ) this.name = args[1];
else this.name = getRuntime().getNil();
super.initialize(NULL_ARRAY, block); // message already set
Expand All @@ -229,12 +229,12 @@ public IRubyObject initialize(IRubyObject[] args, Block block) {
@JRubyMethod
@Override
public IRubyObject to_s(ThreadContext context) {
if (getMessage().isNil()) {
if (message.isNil()) {
return context.runtime.newString(getMetaClass().getRealClass().getName());
}
RubyString str = getMessage().convertToString();
if (str != getMessage()) setMessage(str);
return getMessage();
RubyString str = message.convertToString();
if (str != message) message = str;
return message;
}

@JRubyMethod
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/RubyString.java
Expand Up @@ -1314,6 +1314,7 @@ public final RubyString cat(byte[] str) {

public final RubyString cat(byte[] str, int beg, int len) {
modify(value.getRealSize() + len);
if (len == 0) return this;
System.arraycopy(str, beg, value.getUnsafeBytes(), value.getBegin() + value.getRealSize(), len);
value.setRealSize(value.getRealSize() + len);
return this;
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubySymbol.java
Expand Up @@ -898,6 +898,10 @@ public RubyArray all_symbols() {
return array;
}

public int size() {
return size;
}

private SymbolEntry[] rehash() {
SymbolEntry[] oldTable = symbolTable;
int oldCapacity = oldTable.length;
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/RubySystemCallError.java
Expand Up @@ -139,7 +139,6 @@ public IRubyObject allocate(Ruby runtime, RubyClass klass) {

private static final ObjectMarshal SYSTEM_CALL_ERROR_MARSHAL = new ObjectMarshal() {
@Override
@SuppressWarnings("deprecation")
public void marshalTo(Ruby runtime, Object obj, RubyClass type,
MarshalStream marshalStream) throws IOException {
RubySystemCallError exc = (RubySystemCallError) obj;
Expand All @@ -163,7 +162,7 @@ public Object unmarshalFrom(Ruby runtime, RubyClass type,
// just use real vars all the time for these?
unmarshalStream.defaultVariablesUnmarshal(exc);

exc.setMessage((IRubyObject)exc.removeInternalVariable("mesg"));
exc.message = (IRubyObject)exc.removeInternalVariable("mesg");
exc.errno = (IRubyObject)exc.removeInternalVariable("errno");
exc.set_backtrace((IRubyObject)exc.removeInternalVariable("bt"));

Expand Down Expand Up @@ -255,7 +254,7 @@ public IRubyObject initialize(IRubyObject[] args, Block block) {
val += " - " + msg.convertToString();
}

setMessage(runtime.newString(val));
message = runtime.newString(val);
return this;
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubySystemExit.java
Expand Up @@ -73,15 +73,15 @@ public IRubyObject initialize(IRubyObject[] args, Block block) {
final IRubyObject arg = args[0];
if (arg instanceof RubyFixnum) {
this.status = arg;
if (args.length > 1) this.setMessage(args[1]); // (status, message)
if (args.length > 1) this.message = args[1]; // (status, message)
}
else if (arg instanceof RubyBoolean) {
final Ruby runtime = getRuntime();
this.status = runtime.newFixnum( arg == runtime.getTrue() ? 0 : 1 );
if (args.length > 1) this.setMessage(args[1]); // (status, message)
if (args.length > 1) this.message = args[1]; // (status, message)
}
else {
this.setMessage(arg);
this.message = arg;
this.status = RubyFixnum.zero(getRuntime());
}
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/RubyUncaughtThrowError.java
Expand Up @@ -57,23 +57,23 @@ static RubyClass createUncaughtThrowErrorClass(Ruby runtime, RubyClass argumentE
protected RubyUncaughtThrowError(Ruby runtime, RubyClass exceptionClass) {
super(runtime, exceptionClass, exceptionClass.getName());
// this.tag = this.value = runtime.getNil();
this.setMessage(runtime.getNil());
this.message = runtime.getNil();
}

public static RubyUncaughtThrowError newUncaughtThrowError(final Ruby runtime,
IRubyObject tag, IRubyObject value, RubyString message) {
RubyUncaughtThrowError error = new RubyUncaughtThrowError(runtime, runtime.getUncaughtThrowError());
error.tag = tag;
error.value = value;
error.setMessage(message);
error.message = message;
return error;
}

@Override
@JRubyMethod(required = 2, optional = 1, visibility = Visibility.PRIVATE)
public IRubyObject initialize(IRubyObject[] args, Block block) {
this.tag = args[0]; this.value = args[1];
if ( args.length > 2 ) this.setMessage(args[2]);
if ( args.length > 2 ) this.message = args[2];
// makes no-sense for us to have a cause or does it ?!
// super.initialize(NULL_ARRAY, block); // already set message
return this;
Expand All @@ -87,12 +87,12 @@ public IRubyObject initialize(IRubyObject[] args, Block block) {

@Override
public RubyString to_s(ThreadContext context) {
if ( getMessage().isNil() ) {
if ( message.isNil() ) {
return RubyString.newEmptyString(context.runtime);
}
if ( tag == null ) return getMessage().asString();
if ( tag == null ) return message.asString();

final RubyString str = getMessage().asString();
final RubyString str = message.asString();
return str.op_format(context, RubyArray.newArray(context.runtime, tag));
}

Expand Down
Expand Up @@ -1354,14 +1354,12 @@ public IRubyObject precs(ThreadContext context) {

@JRubyMethod(name = "round", optional = 2)
public IRubyObject round(ThreadContext context, IRubyObject[] args) {
final int scale = args.length > 0 ? num2int(args[0]) : 0;

// Special treatment for BigDecimal::NAN and BigDecimal::INFINITY
//
// If round is called without any argument, we should raise a
// FloatDomainError. Otherwise, we don't have to call round ;
// we can simply return the number itself.
if (scale == 0 && isInfinity()) {
if (args.length == 0 && isInfinity()) {
StringBuilder message = new StringBuilder("Computation results to ");
message.append('\'').append(callMethod(context, "to_s")).append('\'');

Expand All @@ -1373,6 +1371,7 @@ public IRubyObject round(ThreadContext context, IRubyObject[] args) {
}
}

final int scale = args.length > 0 ? num2int(args[0]) : 0;
RoundingMode mode = (args.length > 1) ? javaRoundingModeFromRubyRoundingMode(context.runtime, args[1]) : getRoundingMode(context.runtime);
// JRUBY-914: Java 1.4 BigDecimal does not allow a negative scale, so we have to simulate it
final RubyBigDecimal bigDecimal;
Expand Down

0 comments on commit faf00ed

Please sign in to comment.