8273790: Potential cyclic dependencies between Gregorian and CalendarSystem

Reviewed-by: naoto, yyang, rriggs
This commit is contained in:
Jaikiran Pai 2021-09-28 05:00:27 +00:00
parent 633eab23f0
commit ddc262746a
2 changed files with 183 additions and 4 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -111,7 +111,9 @@ public abstract class CalendarSystem {
}
}
private static final Gregorian GREGORIAN_INSTANCE = new Gregorian();
private static final class GregorianHolder {
private static final Gregorian GREGORIAN_INSTANCE = new Gregorian();
}
/**
* Returns the singleton instance of the <code>Gregorian</code>
@ -120,7 +122,7 @@ public abstract class CalendarSystem {
* @return the <code>Gregorian</code> instance
*/
public static Gregorian getGregorianCalendar() {
return GREGORIAN_INSTANCE;
return GregorianHolder.GREGORIAN_INSTANCE;
}
/**
@ -135,7 +137,7 @@ public abstract class CalendarSystem {
*/
public static CalendarSystem forName(String calendarName) {
if ("gregorian".equals(calendarName)) {
return GREGORIAN_INSTANCE;
return GregorianHolder.GREGORIAN_INSTANCE;
}
if (!initialized) {