Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move these keys to constants.
Browse files Browse the repository at this point in the history
headius committed Sep 6, 2017
1 parent ef66985 commit 5dccc5a
Showing 5 changed files with 35 additions and 10 deletions.
12 changes: 8 additions & 4 deletions core/src/main/java/org/jruby/RubyException.java
Original file line number Diff line number Diff line change
@@ -339,6 +339,10 @@ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
}
};

public static final String MESSAGE_KEY = "mesg";
public static final String BACKTRACE_KEY = "bt";
public static final String ERRNO_KEY = "errno";

private static final ObjectMarshal EXCEPTION_MARSHAL = new ObjectMarshal() {
@Override
public void marshalTo(Ruby runtime, Object obj, RubyClass type,
@@ -347,8 +351,8 @@ public void marshalTo(Ruby runtime, Object obj, RubyClass type,

marshalStream.registerLinkTarget(exc);
List<Variable<Object>> attrs = exc.getVariableList();
attrs.add(new VariableEntry<Object>("mesg", exc.getMessage()));
attrs.add(new VariableEntry<Object>("bt", exc.getBacktrace()));
attrs.add(new VariableEntry<Object>(MESSAGE_KEY, exc.getMessage()));
attrs.add(new VariableEntry<Object>(BACKTRACE_KEY, exc.getBacktrace()));
marshalStream.dumpVariables(attrs);
}

@@ -362,8 +366,8 @@ 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.set_backtrace((IRubyObject)exc.removeInternalVariable("bt"));
exc.setMessage((IRubyObject)exc.removeInternalVariable(MESSAGE_KEY));
exc.set_backtrace((IRubyObject)exc.removeInternalVariable(BACKTRACE_KEY));

return exc;
}
12 changes: 6 additions & 6 deletions core/src/main/java/org/jruby/RubySystemCallError.java
Original file line number Diff line number Diff line change
@@ -146,9 +146,9 @@ public void marshalTo(Ruby runtime, Object obj, RubyClass type,

List<Variable<Object>> attrs = exc.getVariableList();
attrs.add(new VariableEntry<Object>(
"mesg", exc.message == null ? runtime.getNil() : exc.message));
attrs.add(new VariableEntry<Object>("errno", exc.errno));
attrs.add(new VariableEntry<Object>("bt", exc.getBacktrace()));
MESSAGE_KEY, exc.message == null ? runtime.getNil() : exc.message));
attrs.add(new VariableEntry<Object>(ERRNO_KEY, exc.errno));
attrs.add(new VariableEntry<Object>(BACKTRACE_KEY, exc.getBacktrace()));
marshalStream.dumpVariables(attrs);
}

@@ -162,9 +162,9 @@ public Object unmarshalFrom(Ruby runtime, RubyClass type,
// just use real vars all the time for these?
unmarshalStream.defaultVariablesUnmarshal(exc);

exc.message = (IRubyObject)exc.removeInternalVariable("mesg");
exc.errno = (IRubyObject)exc.removeInternalVariable("errno");
exc.set_backtrace((IRubyObject)exc.removeInternalVariable("bt"));
exc.message = (IRubyObject)exc.removeInternalVariable(MESSAGE_KEY);
exc.errno = (IRubyObject)exc.removeInternalVariable(ERRNO_KEY);
exc.set_backtrace((IRubyObject)exc.removeInternalVariable(BACKTRACE_KEY));

return exc;
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/exceptions/Exception.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jruby.exceptions;

/**
* Created by headius on 9/6/17.
*/
public class Exception {
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/exceptions/IOError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jruby.exceptions;

/**
* Created by headius on 9/6/17.
*/
public class IOError {
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/exceptions/StandardError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jruby.exceptions;

/**
* Created by headius on 9/6/17.
*/
public class StandardError {
}

0 comments on commit 5dccc5a

Please sign in to comment.