[code-reflection] RFR: throw instead returning when erasing checked to unchecked exception [v2]
Hannes Greule
hgreule at openjdk.org
Thu Jan 18 08:40:13 UTC 2024
On Wed, 17 Jan 2024 19:05:55 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> Hannes Greule has updated the pull request incrementally with one additional commit since the last revision:
>>
>> address comments
>
> test/jdk/java/lang/reflect/code/interpreter/TestThrowing.java line 49:
>
>> 47: } catch (Throwable throwable) {
>> 48: Assert.assertEquals(throwable.getClass(), expectedExceptionType);
>> 49: }
>
> I believe you can replace the try statement with:
> ```java
> Assert.assertThrows(expectedExceptionType,
> () -> Interpreter.invoke(method.getCodeModel().orElseThrow(), List.of()));
Yes, that's definitely cleaner, done.
> test/jdk/java/lang/reflect/code/interpreter/TestThrowing.java line 55:
>
>> 53: static Object[][] testData() throws NoSuchMethodException {
>> 54: return new Object[][]{
>> 55: {"throwsError", Error.class},
>
> Suggestion, up to you. Use specific exception to this test, there by differentiating between generic ones that might be thrown in error e.g., create `static class TestError extends Error {}`
Done too, however I had to explicitly pass `MethodHandles.lookup()` now as the classes couldn't be found otherwise. I'm not sure why exactly though, as they are public.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/2#discussion_r1457096124
PR Review Comment: https://git.openjdk.org/babylon/pull/2#discussion_r1457097428
More information about the babylon-dev
mailing list