Skip to content

Commit

Permalink
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
@@ -63,6 +63,9 @@
*/
@JRubyClass(name="Struct")
public class RubyStruct extends RubyObject {
public static final String NO_MEMBER_IN_STRUCT = "no member '%s' in struct";
public static final String IDENTIFIER_NEEDS_TO_BE_CONSTANT = "identifier %s needs to be constant";
public static final String UNINITIALIZED_CONSTANT = "uninitialized constant %s";
private final IRubyObject[] values;

/**
@@ -203,7 +206,7 @@ public static RubyClass newInstance(IRubyObject recv, IRubyObject[] args, Block
newStruct.inherit(superClass);
} else {
if (!IdUtil.isConstant(name)) {
throw runtime.newNameError("identifier " + name + " needs to be constant", name);
throw runtime.newNameError(IDENTIFIER_NEEDS_TO_BE_CONSTANT, recv, name);
}

IRubyObject type = superClass.getConstantAt(name);
@@ -466,7 +469,7 @@ public IRubyObject set(IRubyObject value, int index) {
}

private RaiseException notStructMemberError(String name) {
return getRuntime().newNameError("no member '" + name + "' in struct", this, name);
return getRuntime().newNameError(NO_MEMBER_IN_STRUCT, this, name);
}

public final IRubyObject get(int index) {
@@ -765,7 +768,7 @@ public static RubyStruct unmarshalFrom(UnmarshalStream input) throws java.io.IOE
RubySymbol className = (RubySymbol) input.unmarshalObject(false);
RubyClass rbClass = pathToClass(runtime, className.asJavaString());
if (rbClass == null) {
throw runtime.newNameError("uninitialized constant " + className, className.asJavaString());
throw runtime.newNameError(UNINITIALIZED_CONSTANT, runtime.getStructClass(), className);
}

final RubyArray member = __member__(rbClass);
1 change: 1 addition & 0 deletions test/jruby.index
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ jruby/test_jruby_internals
jruby/test_marshal_with_instance_variables
jruby/test_marshal_gemspec
jruby/test_method_missing
jruby/test_name_error
jruby/test_no_stack_trace_stomp
jruby/test_pack
jruby/test_primitive_to_java

0 comments on commit 28594d8

Please sign in to comment.