RFR: 8319987: compilation of sealed classes leads to infinite recursion

Vicente Romero vromero at openjdk.org
Wed Nov 15 04:28:35 UTC 2023


The compiler can throw a SOE when trying to compile an incorrect sealed classes hierarchy like:

    sealed interface Action permits Add {}
    sealed interface MathOp permits Add {}
    sealed static class Add implements MathOp permits Add {}

The error is thrown while trying to prove if two classes are disjoint or not. The proposed solution is to keep a set with the pairs of classes analyzed so far and stop as soon as a the current pair of classes is already in the set.

TIA

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

Commit messages:
 - 8319987: compilation of sealed classes leads to infinite recursion

Changes: https://git.openjdk.org/jdk/pull/16668/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16668&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8319987
  Stats: 58 lines in 3 files changed: 33 ins; 6 del; 19 mod
  Patch: https://git.openjdk.org/jdk/pull/16668.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16668/head:pull/16668

PR: https://git.openjdk.org/jdk/pull/16668


More information about the compiler-dev mailing list