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

Tobias Hartmann thartmann at openjdk.java.net
Mon May 17 13:05:14 UTC 2021


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

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

Commit messages:
 - 8266615: C2 incorrectly folds subtype checks involving an interface array

Changes: https://git.openjdk.java.net/jdk/pull/4060/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4060&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8266615
  Stats: 87 lines in 2 files changed: 85 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4060.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4060/head:pull/4060

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


More information about the hotspot-compiler-dev mailing list