mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8273790: Potential cyclic dependencies between Gregorian and CalendarSystem
Reviewed-by: naoto, yyang, rriggs
This commit is contained in:
parent
633eab23f0
commit
ddc262746a
2 changed files with 183 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue