Skip to content

Commit 735bdfa

Browse files
committed
[GR-58634] Fix error message when prepareOSR long overload is not implemented
PullRequest: graal/18950
2 parents 9f2747b + 6a117ba commit 735bdfa

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/BytecodeOSRNodeTest.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
*/
2525
package jdk.graal.compiler.truffle.test;
2626

27+
import static org.junit.Assert.assertTrue;
28+
import static org.junit.Assert.fail;
29+
2730
import java.io.ByteArrayOutputStream;
2831
import java.io.IOException;
2932
import java.util.concurrent.TimeUnit;
@@ -709,7 +712,7 @@ public void testLongTargetBadOverload1() {
709712
FixedIterationLoopLongTargetLoopBadOverload1 osrNode = new FixedIterationLoopLongTargetLoopBadOverload1(frameBuilder);
710713
RootNode rootNode = new Program(osrNode, frameBuilder.build());
711714
OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget();
712-
Assert.assertThrows("long target used without implementing long overload of prepareOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1));
715+
assertThrowsWithMessage("long target used without implementing long overload of prepareOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1));
713716
}
714717

715718
@Test
@@ -718,7 +721,7 @@ public void testLongTargetBadOverload2() {
718721
FixedIterationLoopLongTargetLoopBadOverload2 osrNode = new FixedIterationLoopLongTargetLoopBadOverload2(frameBuilder);
719722
RootNode rootNode = new Program(osrNode, frameBuilder.build());
720723
OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget();
721-
Assert.assertThrows("long target used without implementing long overload of copyIntoOSRFrame", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1));
724+
assertThrowsWithMessage("long target used without implementing long overload of copyIntoOSRFrame", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1));
722725
}
723726

724727
@Test
@@ -727,7 +730,18 @@ public void testLongTargetBadOverload3() {
727730
FixedIterationLoopLongTargetLoopBadOverload3 osrNode = new FixedIterationLoopLongTargetLoopBadOverload3(frameBuilder);
728731
RootNode rootNode = new Program(osrNode, frameBuilder.build());
729732
OptimizedCallTarget target = (OptimizedCallTarget) rootNode.getCallTarget();
730-
Assert.assertThrows("long target used without implementing long overload of executeOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1));
733+
assertThrowsWithMessage("long target used without implementing long overload of executeOSR", AssertionError.class, () -> target.call(OSR_THRESHOLD + 1));
734+
}
735+
736+
private static void assertThrowsWithMessage(String errorMessage, Class<?> expectedThrowable, Runnable runnable) {
737+
try {
738+
runnable.run();
739+
} catch (Throwable t) {
740+
assertTrue(expectedThrowable.isInstance(t));
741+
assertTrue(t.getMessage().contains(errorMessage));
742+
return;
743+
}
744+
fail("No exception was thrown.");
731745
}
732746

733747
public static class Program extends RootNode {

truffle/src/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/BytecodeOSRNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ default void prepareOSR(int target) {
292292
default void prepareOSR(long target) {
293293
int intTarget = (int) target;
294294
if (intTarget != target) {
295-
throw CompilerDirectives.shouldNotReachHere("long target used without implementing long overload of executeOSR");
295+
throw CompilerDirectives.shouldNotReachHere("long target used without implementing long overload of prepareOSR");
296296
}
297297
prepareOSR(intTarget);
298298
}

0 commit comments

Comments
 (0)