Skip to content

Commit

Permalink
Merge branch 'ruby-2.3' into ruby-2.3+socket
Browse files Browse the repository at this point in the history
headius committed Feb 18, 2016

Verified

This commit was signed with the committer’s verified signature.
wyattjoh Wyatt Johnson
2 parents 2029231 + e0450e5 commit 48c0468
Showing 775 changed files with 16,840 additions and 15,254 deletions.
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.1/apache-maven-3.3.1-bin.zip
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip
11 changes: 1 addition & 10 deletions bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -234,16 +234,7 @@ do
-*)
opt="${opt:1}=false" ;;
esac
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
elif [ "${val:0:15}" = "-Djvmci.option." ]; then # Graal options
opt=${val:15}
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
elif [ "${val:0:15}" = "-Dgraal.option." ]; then # Graal options
opt=${val:15}
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
elif [ "${val:0:8}" = "-Dgraal." ]; then # Graal options
opt=${val:8}
java_args=("${java_args[@]}" "-Djvmci.option.$opt")
java_args=("${java_args[@]}" "-Dgraal.$opt")
else
if [ "${val:0:3}" = "-ea" ]; then
VERIFY_JRUBY="yes"
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -258,10 +258,10 @@ public Status run() {
private Status internalRun() {
doShowVersion();
doShowCopyright();
doPrintProperties();

if (!config.getShouldRunInterpreter() ) {
if (!config.getShouldRunInterpreter()) {
doPrintUsage(false);
doPrintProperties();
return new Status();
}

17 changes: 7 additions & 10 deletions core/src/main/java/org/jruby/NativeException.java
Original file line number Diff line number Diff line change
@@ -42,18 +42,15 @@ public class NativeException extends RubyException {

private final Throwable cause;
public static final String CLASS_NAME = "NativeException";
private final Ruby runtime;

public NativeException(Ruby runtime, RubyClass rubyClass, Throwable cause) {
super(runtime, rubyClass);
this.runtime = runtime;
this.cause = cause;
this.message = runtime.newString(cause.getClass().getName() + ": " + searchStackMessage(cause));
}

private NativeException(Ruby runtime, RubyClass rubyClass) {
super(runtime, rubyClass);
this.runtime = runtime;
this.cause = new Throwable();
this.message = runtime.newString();
}
@@ -84,6 +81,7 @@ public IRubyObject backtrace() {
if (rubyTrace.isNil()) {
return rubyTrace;
}
final Ruby runtime = getRuntime();
RubyArray array = (RubyArray) rubyTrace.dup();
StackTraceElement[] stackTrace = cause.getStackTrace();
for (int i = stackTrace.length - 1; i >= 0; i--) {
@@ -97,12 +95,12 @@ public IRubyObject backtrace() {
final String packageName = index == -1 ? "" : className.substring(0, index) + '/';
line = packageName.replace('.', '/') + element.getFileName() + ':' + element.getLineNumber() + ":in `" + element.getMethodName() + '\'';
}
RubyString string = runtime.newString(line);
array.unshift(string);
array.unshift(runtime.newString(line));
}
return array;
}

@Deprecated // not used
public void trimStackTrace(Member target) {
Throwable t = new Throwable();
StackTraceElement[] origStackTrace = cause.getStackTrace();
@@ -143,19 +141,18 @@ public void trimStackTrace(Member target) {

public void printBacktrace(PrintStream errorStream) {
super.printBacktrace(errorStream);
if (getRuntime().getDebug().isTrue()) {
if (getRuntime().isDebug()) {
errorStream.println("Complete Java stackTrace");
cause.printStackTrace(errorStream);
}
}

public Throwable getCause() {
public final Throwable getCause() {
return cause;
}

private String searchStackMessage(Throwable cause) {
String message = null;

private static String searchStackMessage(Throwable cause) {
String message;
do {
message = cause.getMessage();
cause = cause.getCause();
11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -841,8 +841,11 @@ public IRubyObject runInterpreter(ThreadContext context, Node rootNode, IRubyObj
assert self == getTopSelf();
final JRubyTruffleInterface truffleContext = getTruffleContext();
Main.printTruffleTimeMetric("before-run");
truffleContext.execute((RootNode) rootNode);
Main.printTruffleTimeMetric("after-run");
try {
truffleContext.execute((RootNode) rootNode);
} finally {
Main.printTruffleTimeMetric("after-run");
}
return getNil();
} else {
return interpreter.execute(this, rootNode, self);
@@ -890,7 +893,7 @@ public JRubyTruffleInterface getTruffleContext() {
}

private JRubyTruffleInterface loadTruffle() {
Main.printTruffleTimeMetric("before-load-truffle-context");
Main.printTruffleTimeMetric("before-load-context");

final Class<?> clazz;

@@ -909,7 +912,7 @@ private JRubyTruffleInterface loadTruffle() {
throw new RuntimeException("Error while calling the constructor of Truffle's RubyContext", e);
}

Main.printTruffleTimeMetric("after-load-truffle-context");
Main.printTruffleTimeMetric("after-load-context");

return truffleContext;
}
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;
}

14 changes: 11 additions & 3 deletions core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ public RubyException(Ruby runtime, RubyClass rubyClass, String message) {
super(runtime, rubyClass);

this.message = message == null ? runtime.getNil() : runtime.newString(message);
this.cause = runtime.getNil();
this.cause = RubyBasicObject.UNDEF;
}

@JRubyMethod(optional = 2, visibility = PRIVATE)
@@ -99,7 +99,7 @@ private void setBacktrace(IRubyObject obj) {
} else if (obj instanceof RubyString) {
backtrace = RubyArray.newArray(getRuntime(), obj);
} else {
throw getRuntime().newTypeError("backtrace must be Array of String or a single String");
throw getRuntime().newTypeError("backtrace must be Array of String");
}
}

@@ -196,13 +196,21 @@ public static IRubyObject op_eqq(ThreadContext context, IRubyObject recv, IRubyO
@JRubyMethod(name = "cause")
public IRubyObject cause(ThreadContext context) {
assert cause != null;

if (cause == RubyBasicObject.UNDEF) return context.nil;

return cause;
}

public void setCause(IRubyObject cause) {
this.cause = cause;
}

// NOTE: can not have IRubyObject as NativeException has getCause() returning Throwable
public Object getCause() {
return cause;
}

public void setBacktraceData(BacktraceData backtraceData) {
this.backtraceData = backtraceData;
}
@@ -386,7 +394,7 @@ public IRubyObject getMessage() {
private BacktraceData backtraceData;
private IRubyObject backtrace;
public IRubyObject message;
private IRubyObject cause;
IRubyObject cause;

public static final int TRACE_HEAD = 8;
public static final int TRACE_TAIL = 4;
10 changes: 5 additions & 5 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -171,6 +171,8 @@ public static RubyClass createFileClass(Ruby runtime) {
/* disable line code conversion */
constants.setConstant("BINARY", runtime.newFixnum(OpenFlags.O_BINARY.intValue()));
}
// FIXME: Need Windows value for this
constants.setConstant("SHARE_DELETE", runtime.newFixnum(0));
if (OpenFlags.O_SYNC.defined()) {
/* any write operation perform synchronously */
constants.setConstant("SYNC", runtime.newFixnum(OpenFlags.O_SYNC.intValue()));
@@ -1235,7 +1237,7 @@ public static IRubyObject mkfifo(ThreadContext context, IRubyObject recv, IRubyO

public static IRubyObject mkfifo(ThreadContext context, RubyString path, int mode) {
Ruby runtime = context.runtime;
String decodedPath = path.toString();
String decodedPath = JRubyFile.createResource(runtime, path.toString()).absolutePath();

if (runtime.getPosix().mkfifo(decodedPath, mode) != 0) {
throw runtime.newErrnoFromInt(runtime.getPosix().errno(), decodedPath);
@@ -1397,10 +1399,8 @@ public static FileResource fileResource(ThreadContext context, IRubyObject pathO
public static FileResource fileResource(IRubyObject pathOrFile) {
Ruby runtime = pathOrFile.getRuntime();

if (pathOrFile instanceof RubyFile) {
return JRubyFile.createResource(runtime, ((RubyFile) pathOrFile).getPath());
} else if (pathOrFile instanceof RubyIO) {
return JRubyFile.createResource(runtime, ((RubyIO) pathOrFile).openFile.getPath());
if (pathOrFile instanceof RubyIO) {
return JRubyFile.createResource(runtime, ((RubyIO) pathOrFile).getOpenFileChecked().getPath());
}

ThreadContext context = runtime.getCurrentContext();
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyGlobal.java
Original file line number Diff line number Diff line change
@@ -750,7 +750,7 @@ public IRubyObject get() {
@Override
public IRubyObject set(IRubyObject value) {
if (runtime.getGlobalVariables().get("$!").isNil()) {
throw runtime.newArgumentError("$! not set.");
throw runtime.newArgumentError("$! not set");
}
runtime.getGlobalVariables().get("$!").callMethod(value.getRuntime().getCurrentContext(), "set_backtrace", value);
return value;
24 changes: 6 additions & 18 deletions core/src/main/java/org/jruby/RubyIO.java
Original file line number Diff line number Diff line change
@@ -3736,13 +3736,13 @@ private void setupPopen(ModeFlags modes, POpenProcess process) throws RaiseExcep
}

private static class Ruby19POpen {
public final RubyString cmd;
public final IRubyObject[] cmdPlusArgs;
public final RubyHash env;
final RubyString cmd;
final IRubyObject[] cmdPlusArgs;
final RubyHash env;

public Ruby19POpen(Ruby runtime, IRubyObject[] args) {
IRubyObject[] _cmdPlusArgs = null;
IRubyObject _env = null;
Ruby19POpen(Ruby runtime, IRubyObject[] args) {
IRubyObject[] _cmdPlusArgs;
IRubyObject _env;
IRubyObject _cmd;

int firstArg = 0;
@@ -3858,18 +3858,6 @@ public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyOb
process = ShellLauncher.popen(runtime, r19Popen.cmdPlusArgs, r19Popen.env, modes);
}

// Yes, this is gross. java.lang.Process does not appear to be guaranteed
// "ready" when we get it back from Runtime#exec, so we try to give it a
// chance by waiting for 10ms before we proceed. Only doing this on 1.5
// since Hotspot 1.6+ does not seem to exhibit the problem.
if (System.getProperty("java.specification.version", "").equals("1.5")) {
synchronized (process) {
try {
process.wait(100);
} catch (InterruptedException ie) {}
}
}

checkPopenOptions(options);

io.setupPopen(modes, process);
43 changes: 30 additions & 13 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@
import java.util.HashSet;
import java.util.Map;

import static org.jruby.RubyBasicObject.UNDEF;
import static org.jruby.RubyEnumerator.enumeratorizeWithSize;
import static org.jruby.anno.FrameField.BLOCK;
import static org.jruby.anno.FrameField.FILENAME;
@@ -163,7 +164,7 @@ public static IRubyObject autoload(ThreadContext context, final IRubyObject recv
final Ruby runtime = context.runtime;
final String nonInternedName = symbol.asJavaString();

if (!IdUtil.isValidConstantName(nonInternedName)) {
if (!IdUtil.isValidConstantName19(nonInternedName)) {
throw runtime.newNameError("autoload must be constant name", nonInternedName);
}

@@ -432,7 +433,13 @@ public static IRubyObject new_string(ThreadContext context, IRubyObject recv, IR

@JRubyMethod(name = "String", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject new_string19(ThreadContext context, IRubyObject recv, IRubyObject object) {
return TypeConverter.convertToType19(object, context.runtime.getString(), "to_s");
Ruby runtime = context.runtime;

IRubyObject tmp = TypeConverter.checkStringType(runtime, object);
if (tmp.isNil()) {
tmp = TypeConverter.convertToType19(object, context.runtime.getString(), "to_s");
}
return tmp;
}

// MRI: rb_f_p_internal
@@ -842,7 +849,9 @@ public static IRubyObject raise(ThreadContext context, IRubyObject recv, IRubyOb
printExceptionSummary(context, runtime, raise.getException());
}

if ( argc > 0 && cause != raise.getException() ) raise.getException().setCause(cause);
if (argc > 0 && raise.getException().getCause() == UNDEF) {
raise.getException().setCause(cause);
}

throw raise;
}
@@ -1509,9 +1518,10 @@ public static IRubyObject system(ThreadContext context, IRubyObject recv, IRubyO

@JRubyMethod(name = "system", required = 1, rest = true, module = true, visibility = PRIVATE)
public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Ruby runtime = context.runtime;
final Ruby runtime = context.runtime;
boolean needChdir = !runtime.getCurrentDirectory().equals(runtime.getPosix().getcwd());

if (runtime.getPosix().isNative() && !Platform.IS_WINDOWS) {
if (!needChdir && runtime.getPosix().isNative() && !Platform.IS_WINDOWS) {
// MRI: rb_f_system
long pid;
int[] status = new int[1];
@@ -1542,14 +1552,14 @@ public static IRubyObject system19(ThreadContext context, IRubyObject recv, IRub
if (pid < 0) {
return runtime.getNil();
}
status[0] = (int)((RubyProcess.RubyStatus)context.getLastExitStatus()).getStatus();
status[0] = (int)((RubyProcess.RubyStatus) context.getLastExitStatus()).getStatus();
if (status[0] == 0) return runtime.getTrue();
return runtime.getFalse();
}

// else old JDK logic
if (args[0] instanceof RubyHash) {
RubyHash env = (RubyHash) args[0].convertToHash();
RubyHash env = args[0].convertToHash();
if (env != null) {
runtime.getENV().merge_bang(context, env, Block.NULL_BLOCK);
}
@@ -1571,11 +1581,7 @@ private static int systemCommon(ThreadContext context, IRubyObject recv, IRubyOb
long[] tuple;

try {
IRubyObject lastArg = args[args.length - 1];
if (lastArg instanceof RubyHash) {
runtime.getWarnings().warn(ID.UNSUPPORTED_SUBPROCESS_OPTION, "system does not support options in JRuby yet: " + lastArg.inspect());
args = Arrays.copyOf(args, args.length - 1);
}
args = dropLastArgIfOptions(runtime, args);
if (! Platform.IS_WINDOWS && args[args.length -1].asJavaString().matches(".*[^&]&\\s*")) {
// looks like we need to send process to the background
ShellLauncher.runWithoutWait(runtime, args);
@@ -1588,7 +1594,18 @@ private static int systemCommon(ThreadContext context, IRubyObject recv, IRubyOb

// RubyStatus uses real native status now, so we unshift Java's shifted exit status
context.setLastExitStatus(RubyProcess.RubyStatus.newProcessStatus(runtime, tuple[0] << 8, tuple[1]));
return (int)tuple[0];
return (int) tuple[0];
}

private static IRubyObject[] dropLastArgIfOptions(final Ruby runtime, final IRubyObject[] args) {
IRubyObject lastArg = args[args.length - 1];
if (lastArg instanceof RubyHash) {
if (!((RubyHash) lastArg).isEmpty()) {
runtime.getWarnings().warn(ID.UNSUPPORTED_SUBPROCESS_OPTION, "system does not support options in JRuby yet: " + lastArg);
}
return Arrays.copyOf(args, args.length - 1);
}
return args;
}

public static IRubyObject exec(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
Loading

0 comments on commit 48c0468

Please sign in to comment.