Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5dccc5a

Browse files
committedSep 6, 2017
Move these keys to constants.
1 parent ef66985 commit 5dccc5a

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed
 

‎core/src/main/java/org/jruby/RubyException.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
339339
}
340340
};
341341

342+
public static final String MESSAGE_KEY = "mesg";
343+
public static final String BACKTRACE_KEY = "bt";
344+
public static final String ERRNO_KEY = "errno";
345+
342346
private static final ObjectMarshal EXCEPTION_MARSHAL = new ObjectMarshal() {
343347
@Override
344348
public void marshalTo(Ruby runtime, Object obj, RubyClass type,
@@ -347,8 +351,8 @@ public void marshalTo(Ruby runtime, Object obj, RubyClass type,
347351

348352
marshalStream.registerLinkTarget(exc);
349353
List<Variable<Object>> attrs = exc.getVariableList();
350-
attrs.add(new VariableEntry<Object>("mesg", exc.getMessage()));
351-
attrs.add(new VariableEntry<Object>("bt", exc.getBacktrace()));
354+
attrs.add(new VariableEntry<Object>(MESSAGE_KEY, exc.getMessage()));
355+
attrs.add(new VariableEntry<Object>(BACKTRACE_KEY, exc.getBacktrace()));
352356
marshalStream.dumpVariables(attrs);
353357
}
354358

@@ -362,8 +366,8 @@ public Object unmarshalFrom(Ruby runtime, RubyClass type,
362366
// just use real vars all the time for these?
363367
unmarshalStream.defaultVariablesUnmarshal(exc);
364368

365-
exc.setMessage((IRubyObject)exc.removeInternalVariable("mesg"));
366-
exc.set_backtrace((IRubyObject)exc.removeInternalVariable("bt"));
369+
exc.setMessage((IRubyObject)exc.removeInternalVariable(MESSAGE_KEY));
370+
exc.set_backtrace((IRubyObject)exc.removeInternalVariable(BACKTRACE_KEY));
367371

368372
return exc;
369373
}

‎core/src/main/java/org/jruby/RubySystemCallError.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ public void marshalTo(Ruby runtime, Object obj, RubyClass type,
146146

147147
List<Variable<Object>> attrs = exc.getVariableList();
148148
attrs.add(new VariableEntry<Object>(
149-
"mesg", exc.message == null ? runtime.getNil() : exc.message));
150-
attrs.add(new VariableEntry<Object>("errno", exc.errno));
151-
attrs.add(new VariableEntry<Object>("bt", exc.getBacktrace()));
149+
MESSAGE_KEY, exc.message == null ? runtime.getNil() : exc.message));
150+
attrs.add(new VariableEntry<Object>(ERRNO_KEY, exc.errno));
151+
attrs.add(new VariableEntry<Object>(BACKTRACE_KEY, exc.getBacktrace()));
152152
marshalStream.dumpVariables(attrs);
153153
}
154154

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

165-
exc.message = (IRubyObject)exc.removeInternalVariable("mesg");
166-
exc.errno = (IRubyObject)exc.removeInternalVariable("errno");
167-
exc.set_backtrace((IRubyObject)exc.removeInternalVariable("bt"));
165+
exc.message = (IRubyObject)exc.removeInternalVariable(MESSAGE_KEY);
166+
exc.errno = (IRubyObject)exc.removeInternalVariable(ERRNO_KEY);
167+
exc.set_backtrace((IRubyObject)exc.removeInternalVariable(BACKTRACE_KEY));
168168

169169
return exc;
170170
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.jruby.exceptions;
2+
3+
/**
4+
* Created by headius on 9/6/17.
5+
*/
6+
public class Exception {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.jruby.exceptions;
2+
3+
/**
4+
* Created by headius on 9/6/17.
5+
*/
6+
public class IOError {
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.jruby.exceptions;
2+
3+
/**
4+
* Created by headius on 9/6/17.
5+
*/
6+
public class StandardError {
7+
}

0 commit comments

Comments
 (0)
Please sign in to comment.