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

Commits on Apr 1, 2016

  1. Copy the full SHA
    f984a60 View commit details
  2. use println on printBacktrace and potentially avoid trace array copy-…

    …ing on toJavaArray
    
    ... also simply print the stack trace element as is if its not a RubyString
    kares committed Apr 1, 2016
    Copy the full SHA
    a74058c View commit details
Showing with 10 additions and 18 deletions.
  1. +0 −8 core/src/main/java/org/jruby/NativeException.java
  2. +10 −10 core/src/main/java/org/jruby/RubyException.java
8 changes: 0 additions & 8 deletions core/src/main/java/org/jruby/NativeException.java
Original file line number Diff line number Diff line change
@@ -150,14 +150,6 @@ public void trimStackTrace(Member target) {
}
}

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

public final Throwable getCause() {
return cause;
}
20 changes: 10 additions & 10 deletions core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -159,8 +159,9 @@ public RubyString inspect(ThreadContext context) {

if (exception.isEmpty()) return context.runtime.newString(rubyClass);

return RubyString.newString(context.runtime, new StringBuilder(2 + rubyClass.length() + 2 + exception.size() + 1).
append("#<").append(rubyClass).append(": ").append(exception.getByteList()).append('>')
return RubyString.newString(context.runtime,
new StringBuilder(2 + rubyClass.length() + 2 + exception.size() + 1).
append("#<").append(rubyClass).append(": ").append(exception.getByteList()).append('>')
);
}

@@ -295,22 +296,21 @@ public void printBacktrace(PrintStream errorStream) {
*/
public void printBacktrace(PrintStream errorStream, int skip) {
IRubyObject trace = callMethod(getRuntime().getCurrentContext(), "backtrace");
if (!trace.isNil() && trace instanceof RubyArray) {
IRubyObject[] elements = trace.convertToArray().toJavaArray();

if ( trace.isNil() ) return;
if ( trace instanceof RubyArray ) {
IRubyObject[] elements = ((RubyArray) trace).toJavaArrayMaybeUnsafe();
for (int i = skip; i < elements.length; i++) {
IRubyObject stackTraceLine = elements[i];
if (stackTraceLine instanceof RubyString) {
printStackTraceLine(errorStream, stackTraceLine);
errorStream.println("\tfrom " + stackTraceLine);
}
else {
errorStream.println("\t" + stackTraceLine);
}
}
}
}

private void printStackTraceLine(PrintStream errorStream, IRubyObject stackTraceLine) {
errorStream.print("\tfrom " + stackTraceLine + '\n');
}

private boolean isArrayOfStrings(IRubyObject backtrace) {
if (!(backtrace instanceof RubyArray)) return false;