@@ -401,9 +401,9 @@ static void warning(String message) {
401
401
public abstract static class ThrowJavaExceptionNode extends CoreMethodArrayArgumentsNode {
402
402
403
403
@ TruffleBoundary
404
- @ Specialization
405
- protected Object throwJavaException (Object message ) {
406
- callingMethod (message . toString ( ));
404
+ @ Specialization ( guards = "isRubyString(message)" )
405
+ protected Object throwJavaException (DynamicObject message ) {
406
+ callingMethod (StringOperations . getString ( message ));
407
407
return nil ;
408
408
}
409
409
@@ -423,21 +423,32 @@ private static void throwingMethod(String message) {
423
423
public abstract static class ThrowJavaExceptionWithCauseNode extends CoreMethodArrayArgumentsNode {
424
424
425
425
@ TruffleBoundary
426
- @ Specialization
427
- protected DynamicObject throwJavaExceptionWithCause (Object message ) {
426
+ @ Specialization ( guards = "isRubyString(message)" )
427
+ protected Object throwJavaExceptionWithCause (DynamicObject message ) {
428
428
throw new RuntimeException (
429
- message . toString ( ),
429
+ StringOperations . getString ( message ),
430
430
new RuntimeException ("cause 1" , new RuntimeException ("cause 2" )));
431
431
}
432
432
433
433
}
434
434
435
+ @ CoreMethod (names = "throw_assertion_error" , onSingleton = true , required = 1 )
436
+ public abstract static class ThrowAssertionErrorNode extends CoreMethodArrayArgumentsNode {
437
+
438
+ @ TruffleBoundary
439
+ @ Specialization (guards = "isRubyString(message)" )
440
+ protected Object throwAssertionError (DynamicObject message ) {
441
+ throw new AssertionError (StringOperations .getString (message ));
442
+ }
443
+
444
+ }
445
+
435
446
@ CoreMethod (names = "assert" , onSingleton = true , required = 1 )
436
447
public abstract static class AssertNode extends CoreMethodArrayArgumentsNode {
437
448
438
449
@ TruffleBoundary
439
450
@ Specialization
440
- protected Object throwJavaException (boolean condition ) {
451
+ protected Object doAssert (boolean condition ) {
441
452
assert condition ;
442
453
return nil ;
443
454
}
@@ -805,7 +816,7 @@ protected String toDisplayString(boolean allowSideEffects) {
805
816
@ TruffleBoundary
806
817
@ Specialization (guards = "isRubyString(string)" )
807
818
protected Object foreignString (DynamicObject string ) {
808
- return new ForeignString (string . toString ( ));
819
+ return new ForeignString (StringOperations . getString ( string ));
809
820
}
810
821
811
822
}
0 commit comments