final ByteArrayOutputStream err = new ByteArrayOutputStream();
RubyInstanceConfig config = new RubyInstanceConfig() {{
setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
}};
Ruby ruby = Ruby.newInstance(config);
RubyException exception = (RubyException)runtime.getClass("NameError").newInstance(ruby.getCurrentContext(), new IRubyObject[]{ruby.newString("A message")}, Block.NULL_BLOCK);
RubyString[] lines = new RubyString[]{
RubyString.newString(ruby, "Line 1"),
RubyString.newString(ruby, "Line 2"),
};
RubyArray backtrace = RubyArray.newArray(ruby, Arrays.asList(lines));