Skip to content

Commit f3cb0e8

Browse files
committed
[GR-17457] Annotate all Ruby Throwable classes to make it easy to list them
PullRequest: truffleruby/3881
2 parents 897973d + 53b1a2e commit f3cb0e8

14 files changed

+48
-19
lines changed

src/main/java/org/truffleruby/cext/CExtNodes.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,8 @@ protected int extractRubyTag(CapturedException captured,
15401540
@GenerateCached(false)
15411541
public abstract static class ExtractRubyTagHelperNode extends RubyBaseNode {
15421542

1543-
public abstract int execute(Node node, Throwable e);
1543+
// Object instead of Throwable to workaround Truffle DSL bug GR-46797
1544+
public abstract int execute(Node node, Object e);
15441545

15451546
@Specialization
15461547
protected static int dynamicReturnTag(DynamicReturnException e) {
@@ -1582,8 +1583,9 @@ protected static int throwTag(ThrowException e) {
15821583
return RUBY_TAG_THROW;
15831584
}
15841585

1586+
// Object instead of Throwable to workaround Truffle DSL bug GR-46797
15851587
@Fallback
1586-
protected static int noTag(Throwable e) {
1588+
protected static int noTag(Object e) {
15871589
return 0;
15881590
}
15891591
}

src/main/java/org/truffleruby/core/format/exceptions/FormatException.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
package org.truffleruby.core.format.exceptions;
1111

1212
import com.oracle.truffle.api.nodes.ControlFlowException;
13+
import org.truffleruby.language.control.RubyThrowable;
1314

1415
@SuppressWarnings("serial")
15-
public class FormatException extends ControlFlowException {
16+
public class FormatException extends ControlFlowException implements RubyThrowable {
1617

1718
private final String message;
1819

src/main/java/org/truffleruby/language/control/BreakException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010
package org.truffleruby.language.control;
1111

12-
import com.oracle.truffle.api.nodes.ControlFlowException;
1312

1413
@SuppressWarnings("serial")
15-
public final class BreakException extends ControlFlowException {
14+
public final class BreakException extends RubyControlFlowException {
1615

1716
private final BreakID breakID;
1817
private final Object result;

src/main/java/org/truffleruby/language/control/DynamicReturnException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010
package org.truffleruby.language.control;
1111

12-
import com.oracle.truffle.api.nodes.ControlFlowException;
1312

1413
@SuppressWarnings("serial")
15-
public final class DynamicReturnException extends ControlFlowException {
14+
public final class DynamicReturnException extends RubyControlFlowException {
1615

1716
private final ReturnID returnID;
1817
private final Object value;

src/main/java/org/truffleruby/language/control/KillException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/** Used by Thread#kill and to terminate threads. This does run code in ensure. */
2121
@ExportLibrary(InteropLibrary.class)
2222
@SuppressWarnings("serial")
23-
public final class KillException extends AbstractTruffleException {
23+
public final class KillException extends AbstractTruffleException implements RubyThrowable {
2424

2525
@TruffleBoundary
2626
private static RuntimeException javaStacktrace() {

src/main/java/org/truffleruby/language/control/LocalReturnException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010
package org.truffleruby.language.control;
1111

12-
import com.oracle.truffle.api.nodes.ControlFlowException;
1312

1413
@SuppressWarnings("serial")
15-
public final class LocalReturnException extends ControlFlowException {
14+
public final class LocalReturnException extends RubyControlFlowException {
1615

1716
private final Object value;
1817

src/main/java/org/truffleruby/language/control/NextException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010
package org.truffleruby.language.control;
1111

12-
import com.oracle.truffle.api.nodes.ControlFlowException;
1312

1413
@SuppressWarnings("serial")
15-
public final class NextException extends ControlFlowException {
14+
public final class NextException extends RubyControlFlowException {
1615

1716
private final Object result;
1817

src/main/java/org/truffleruby/language/control/RaiseException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/** A ControlFlowException holding a Ruby exception. */
2121
@SuppressWarnings("serial")
2222
@ExportLibrary(value = InteropLibrary.class, delegateTo = "exception")
23-
public final class RaiseException extends AbstractTruffleException {
23+
public final class RaiseException extends AbstractTruffleException implements RubyThrowable {
2424

2525
protected final RubyException exception;
2626

src/main/java/org/truffleruby/language/control/RedoException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
*/
1010
package org.truffleruby.language.control;
1111

12-
import com.oracle.truffle.api.nodes.ControlFlowException;
1312

1413
@SuppressWarnings("serial")
15-
public final class RedoException extends ControlFlowException {
14+
public final class RedoException extends RubyControlFlowException {
1615
}

src/main/java/org/truffleruby/language/control/RetryException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
*/
1010
package org.truffleruby.language.control;
1111

12-
import com.oracle.truffle.api.nodes.ControlFlowException;
1312

1413
@SuppressWarnings("serial")
15-
public final class RetryException extends ControlFlowException {
14+
public final class RetryException extends RubyControlFlowException {
1615
}

0 commit comments

Comments
 (0)