diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/BytecodeOSRNodeTest.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/BytecodeOSRNodeTest.java index 94bdffb49ecc..763612beac05 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/BytecodeOSRNodeTest.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/BytecodeOSRNodeTest.java @@ -24,6 +24,9 @@ */ package jdk.graal.compiler.truffle.test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.concurrent.TimeUnit; @@ -709,7 +712,7 @@ public void testLongTargetBadOverload1() { FixedIterationLoopLongTargetLoopBadOverload1 osrNode = new FixedIterationLoopLongTargetLoopBadOverload1(frameBuilder); RootNode rootNode = new Program(osrNode, frameBuilder.build()); OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget(); - Assert.assertThrows("long target used without implementing long overload of prepareOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1)); + assertThrowsWithMessage("long target used without implementing long overload of prepareOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1)); } @Test @@ -718,7 +721,7 @@ public void testLongTargetBadOverload2() { FixedIterationLoopLongTargetLoopBadOverload2 osrNode = new FixedIterationLoopLongTargetLoopBadOverload2(frameBuilder); RootNode rootNode = new Program(osrNode, frameBuilder.build()); OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget(); - Assert.assertThrows("long target used without implementing long overload of copyIntoOSRFrame", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1)); + assertThrowsWithMessage("long target used without implementing long overload of copyIntoOSRFrame", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1)); } @Test @@ -727,7 +730,18 @@ public void testLongTargetBadOverload3() { FixedIterationLoopLongTargetLoopBadOverload3 osrNode = new FixedIterationLoopLongTargetLoopBadOverload3(frameBuilder); RootNode rootNode = new Program(osrNode, frameBuilder.build()); OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget(); - Assert.assertThrows("long target used without implementing long overload of executeOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1)); + assertThrowsWithMessage("long target used without implementing long overload of executeOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1)); + } + + private static void assertThrowsWithMessage(String errorMessage, Class expectedThrowable, Runnable runnable) { + try { + runnable.run(); + } catch (Throwable t) { + assertTrue(expectedThrowable.isInstance(t)); + assertTrue(t.getMessage().contains(errorMessage)); + return; + } + fail("No exception was thrown."); } public static class Program extends RootNode { diff --git a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BytecodeOSRNode.java b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BytecodeOSRNode.java index d3d6e4e29bdd..05d5aebf0c72 100644 --- a/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BytecodeOSRNode.java +++ b/truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BytecodeOSRNode.java @@ -292,7 +292,7 @@ default void prepareOSR(int target) { default void prepareOSR(long target) { int intTarget = (int) target; if (intTarget != target) { - throw CompilerDirectives.shouldNotReachHere("long target used without implementing long overload of executeOSR"); + throw CompilerDirectives.shouldNotReachHere("long target used without implementing long overload of prepareOSR"); } prepareOSR(intTarget); }