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

Commits on Jan 28, 2016

  1. Copy the full SHA
    016b846 View commit details
  2. Copy the full SHA
    af35877 View commit details
  3. Copy the full SHA
    bcf7618 View commit details
  4. Copy the full SHA
    50fdaa2 View commit details
  5. Copy the full SHA
    825597f View commit details
  6. Copy the full SHA
    107ac4f View commit details
Showing with 57 additions and 46 deletions.
  1. +8 −14 .travis.yml
  2. +2 −3 core/src/main/java/org/jruby/RubyException.java
  3. +7 −5 core/src/main/java/org/jruby/RubyKernel.java
  4. +40 −24 core/src/main/java/org/jruby/RubySystemExit.java
22 changes: 8 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -42,12 +42,12 @@ env:
- PHASE='-Prake -Dtask=spec:jruby'
- PHASE='-Prake -Dtask=spec:jrubyc'
- PHASE='-Prake -Dtask=spec:profiler'
- JT='test specs :language'
- JT='test specs :core'
- JT='test specs :library'
- JT='test specs :truffle'
- JT='test mri'
- JT='test integration'
#- JT='test specs :language'
#- JT='test specs :core'
#- JT='test specs :library'
#- JT='test specs :truffle'
#- JT='test mri'
#- JT='test integration'

matrix:
include:
@@ -73,8 +73,8 @@ matrix:
jdk: oraclejdk8
- env: COMMAND=test/check_versions.sh
jdk: oraclejdk8
- env: JT=check_ambiguous_arguments
jdk: oraclejdk8
#- env: JT=check_ambiguous_arguments
# jdk: oraclejdk8
allow_failures:
- env: PHASE='-Prake -Dtask=test:mri:fullint'
# NOTE: build seems to never start (waited for any to finish for more than a day) - probably a travis-ci bug
@@ -83,12 +83,6 @@ matrix:
# dist: trusty
# group: edge
# jdk: oraclejdk9
allow_failures: # due Ruby-2.3 new features
- env: PHASE='-Ptruffle-specs-language'
- env: PHASE='-Ptruffle-specs-core'
- env: PHASE='-Ptruffle-specs-library'
- env: PHASE='-Ptruffle-specs-truffle'
- env: PHASE='-Ptruffle-mri-tests'

branches:
only:
5 changes: 2 additions & 3 deletions core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -195,9 +195,8 @@ public static IRubyObject op_eqq(ThreadContext context, IRubyObject recv, IRubyO

@JRubyMethod(name = "cause")
public IRubyObject cause(ThreadContext context) {
IRubyObject nil = context.nil;
if (cause != nil) return cause;
return nil;
assert cause != null;
return cause;
}

public void setCause(IRubyObject cause) {
12 changes: 7 additions & 5 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -805,6 +805,11 @@ public static IRubyObject raise(ThreadContext context, IRubyObject recv, IRubyOb
}
}

if ( argc > 0 ) { // for argc == 0 we will be raising $!
// NOTE: getErrorInfo needs to happen before new RaiseException(...)
if ( cause == null ) cause = context.getErrorInfo(); // returns nil for no error-info
}

maybeRaiseJavaException(runtime, args, argc, cause);

RaiseException raise;
@@ -837,10 +842,7 @@ public static IRubyObject raise(ThreadContext context, IRubyObject recv, IRubyOb
printExceptionSummary(context, runtime, raise.getException());
}

if ( argc > 0 ) { // for argc == 0 we're already raising $!
if ( cause == null ) cause = context.getErrorInfo(); // returns nil for no error-info
raise.getException().setCause(cause);
}
if ( argc > 0 && cause != raise.getException() ) raise.getException().setCause(cause);

throw raise;
}
@@ -872,7 +874,7 @@ private static void maybeRaiseJavaException(final Ruby runtime,
if (ex.getCause() == null && cause instanceof ConcreteJavaProxy) {
// allow raise java.lang.RuntimeException.new, cause: myCurrentException()
maybeThrowable = ((ConcreteJavaProxy) cause).getObject();
if (maybeThrowable instanceof Throwable) {
if (maybeThrowable instanceof Throwable && ex != maybeThrowable) {
ex.initCause((Throwable) maybeThrowable);
}
}
64 changes: 40 additions & 24 deletions core/src/main/java/org/jruby/RubySystemExit.java
Original file line number Diff line number Diff line change
@@ -35,29 +35,30 @@

@JRubyClass(name="SystemExit", parent="Exception")
public class RubySystemExit extends RubyException {

IRubyObject status;

private static ObjectAllocator SYSTEMEXIT_ALLOCATOR = new ObjectAllocator() {
private static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
@Override
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
return new RubySystemExit(runtime, klass);
}
};
public static RubyClass createSystemExitClass(Ruby runtime, RubyClass exceptionClass) {
RubyClass systemExitClass = runtime.defineClass("SystemExit", exceptionClass, SYSTEMEXIT_ALLOCATOR);
};

static RubyClass createSystemExitClass(Ruby runtime, RubyClass exceptionClass) {
RubyClass systemExitClass = runtime.defineClass("SystemExit", exceptionClass, ALLOCATOR);

systemExitClass.defineAnnotatedMethods(RubySystemExit.class);

return systemExitClass;
}
}

public static RubySystemExit newInstance(Ruby runtime, int status, String message) {
RubyClass exc = runtime.getSystemExit();
IRubyObject[] exArgs = new IRubyObject[] {
runtime.newFixnum(status),
runtime.newString(message) };
return (RubySystemExit) exc.newInstance(runtime.getCurrentContext(), exArgs, Block.NULL_BLOCK);
final RubyClass klass = runtime.getSystemExit();
final IRubyObject[] args = new IRubyObject[] {
runtime.newFixnum(status), runtime.newString(message)
};
return (RubySystemExit) klass.newInstance(runtime.getCurrentContext(), args, Block.NULL_BLOCK);
}

protected RubySystemExit(Ruby runtime, RubyClass exceptionClass) {
@@ -67,15 +68,27 @@ protected RubySystemExit(Ruby runtime, RubyClass exceptionClass) {

@JRubyMethod(optional = 2, visibility = PRIVATE)
@Override
public IRubyObject initialize(IRubyObject[]args, Block block) {
status = RubyFixnum.zero(getRuntime());
if (args.length > 0 && args[0] instanceof RubyFixnum) {
status = args[0];
IRubyObject[]tmpArgs = new IRubyObject[args.length - 1];
System.arraycopy(args, 1, tmpArgs, 0, tmpArgs.length);
args = tmpArgs;
public IRubyObject initialize(IRubyObject[] args, Block block) {
if (args.length > 0) {
final IRubyObject arg = args[0];
if (arg instanceof RubyFixnum) {
this.status = arg;
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.message = args[1]; // (status, message)
}
else {
this.message = arg;
this.status = RubyFixnum.zero(getRuntime());
}
}
else {
this.status = RubyFixnum.zero(getRuntime());
}
super.initialize(args, block);
super.initialize(NULL_ARRAY, block);
return this;
}

@@ -86,9 +99,12 @@ public IRubyObject status() {

@JRubyMethod(name = "success?")
public IRubyObject success_p() {
if (status.isNil()) return getRuntime().getTrue();
if (status.equals(RubyFixnum.zero(getRuntime()))) return getRuntime().getTrue();
return getRuntime().getFalse();
final Ruby runtime = getRuntime();
final IRubyObject status = this.status;
if ( status.isNil() ) return runtime.getTrue();
if ( status == runtime.getTrue() || status == runtime.getFalse() ) return status;
if ( status.equals(RubyFixnum.zero(runtime)) ) return runtime.getTrue();
return runtime.getFalse();
}

}