RFR: 8266615: C2 incorrectly folds subtype checks involving an interface array

Tobias Hartmann thartmann at openjdk.java.net
Tue May 18 07:28:40 UTC 2021


On Mon, 17 May 2021 12:55:06 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

> C2 incorrectly folds the subtype checks in `TestInterfaceArraySubtypeCheck::test1/test2`. As a result, an unexpected `ClassCastException` is thrown at `checkcast` and `instanceof` returns a wrong result. The problem is in `Compile::static_subtype_check` where we incorrectly return `SSC_always_false` for the `MyInterface[] <: MyClassA[]` check because `MyClassA[]` is not a subtype of `MyInterface[]` (after checking that `MyInterface[]` is not a subtype of `MyClassA[]`).
> 
> The fix is to check that `subelem` is not an interface. This is very old code and not a recent regression.
> 
> Thanks,
> Tobias

Thanks for the review, Vladimir!

-------------

PR: https://git.openjdk.java.net/jdk/pull/4060


More information about the hotspot-compiler-dev mailing list