Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273790

Potential cyclic dependencies between Gregorian and CalendarSystem

XMLWordPrintable

    • b17
    • generic
    • generic
    • Verified

        We find cyclic dependencies between Gregorian and CalendarSystem classes in our test environment when using JDK11 AOT(It also affects JDK tip).

        The class hierarchies are as follows(w/ some simplifications):

        ```
        class GregorianCalendar {
        static Gregorian base = CalendarSystem.getGregorianCalendar();
        }

        class Gregorian extends BaseCalendar { }
        class BaseCalendar extends AbstractCalendar {}
        class AbstractCalendar extends CalendarSystem {}

        public class CalendarSystem {
        Gregorian GREGORIAN_INSTANCE = new Gregorian();
        }
        ```

        We create two new threads to link GregorianCalendar and AbstractCalendar, respectively.

        T1: new GregorianCalendar()
        GregorianCalendar -> Gregorian -> BaseCalendar -> AbstractCalendar -> CalendarSystem

        T2: Unsafe.ensureInitialized(AbstractCalendar.class)
        AbstractCalendar -> CalendarSystem -> Gregorian

        What would next happen, is that application hanging due to deadlock between inGregorian and AbstractCalendar.

          1. aothang.txt
            83 kB
            Yi Yang
          2. aothang2.txt
            39 kB
            Yi Yang

              jpai Jaikiran Pai
              yyang Yi Yang
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: