From e6fb6d04caddc4b410a594574f570cfcb9445e4a Mon Sep 17 00:00:00 2001 From: Evgeny Nikitin Date: Wed, 30 Sep 2020 22:18:17 +0200 Subject: [PATCH] Print all arguments in the invokeAndCheck's exception --- .../string/TestStringIntrinsics.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java index 93968de39d737..2b0d2ad92b5f5 100644 --- a/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java +++ b/test/hotspot/jtreg/compiler/intrinsics/string/TestStringIntrinsics.java @@ -272,15 +272,19 @@ private void invokeAndCompareArrays(Method m, boolean expectedResult, Object arg * returned value equals 'expectedResult'. */ private void invokeAndCheck(Method m, Object expectedResult, Object... args) throws Exception { - Object result = m.invoke(null, args); - if (!result.equals(expectedResult)) { - String message = "Result of '" + m.getName() + "' not equal to expected value."; - System.err.println(message); - System.err.println("Expected: " + Format.asLiteral(expectedResult)); - System.err.println("Result: " + Format.asLiteral(result)); + Object actualResult = m.invoke(null, args); + if (!actualResult.equals(expectedResult)) { + var nl = System.lineSeparator(); + String message = + "Actual result of '" + m.getName() + "' is not equal to expected value." + nl + + "Expected: " + Format.asLiteral(expectedResult) + nl + + "Actual: " + Format.asLiteral(actualResult); + for (int i = 0; i < args.length; i++) { - System.err.println("Arg" + i + ": " + Format.asLiteral(args[i])); + message += nl + " Arg" + i + ": " + Format.asLiteral(args[i]); } + + System.err.println(message); throw new RuntimeException(message); } }