diff --git a/jdk/make/copy/Copy-java.base.gmk b/jdk/make/copy/Copy-java.base.gmk index 9ca554409a6..fd9a0ef3afa 100644 --- a/jdk/make/copy/Copy-java.base.gmk +++ b/jdk/make/copy/Copy-java.base.gmk @@ -48,22 +48,6 @@ $(INCLUDE_DST_OS_DIR)/%.h: \ ################################################################################ -CALENDARS_SRC := $(JDK_TOPDIR)/src/java.base/share/conf - -$(LIB_DST_DIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties - $(call install-file) - -BASE_CONF_FILES += $(LIB_DST_DIR)/calendars.properties - -$(LIB_DST_DIR)/hijrah-config-umalqura.properties: $(CALENDARS_SRC)/hijrah-config-umalqura.properties - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $< $@ - -BASE_CONF_FILES += $(LIB_DST_DIR)/hijrah-config-umalqura.properties - -################################################################################ - ifneq ($(findstring $(OPENJDK_TARGET_OS), windows aix),) TZMAPPINGS_SRC := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/conf diff --git a/jdk/make/profile-includes.txt b/jdk/make/profile-includes.txt index a3c79856e92..226b1ed9eb0 100644 --- a/jdk/make/profile-includes.txt +++ b/jdk/make/profile-includes.txt @@ -54,14 +54,12 @@ PROFILE_1_JRE_LIB_FILES := \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm$(SHARED_LIBRARY_SUFFIX) \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/$(LIBRARY_PREFIX)jvm.diz \ $(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \ - calendars.properties \ classlist \ ext/localedata.jar \ ext/meta-index \ ext/sunec.jar \ ext/sunjce_provider.jar \ ext/sunpkcs11.jar \ - hijrah-config-umalqura.properties \ jce.jar \ jsse.jar \ logging.properties \ diff --git a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java index 7c5005fbe9a..c6c6d4a2e8f 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java @@ -61,13 +61,14 @@ import static java.time.temporal.ChronoField.EPOCH_DAY; import java.io.File; import java.io.FileInputStream; +import java.io.FilePermission; import java.io.IOException; import java.io.InputStream; import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.Serializable; import java.security.AccessController; -import java.security.PrivilegedActionException; +import java.security.PrivilegedAction; import java.time.Clock; import java.time.DateTimeException; import java.time.Instant; @@ -145,29 +146,7 @@ import sun.util.logging.PlatformLogger; * property resource that defines the {@code ID}, the {@code calendar type}, * the start of the calendar, the alignment with the * ISO calendar, and the length of each month for a range of years. - * The variants are identified in the {@code calendars.properties} file. - * The new properties are prefixed with {@code "calendars.hijrah."}: - *
Property Name | - *Property value | - *Description | - *
---|---|---|
calendars.hijrah.{ID} | - *The property resource defining the {@code {ID}} variant | - *The property resource is located with the {@code calendars.properties} file | - *
calendars.hijrah.{ID}.type | - *The calendar type | - *LDML defines the calendar type names | - *
* The Hijrah property resource is a set of properties that describe the calendar. * The syntax is defined by {@code java.util.Properties#load(Reader)}. @@ -279,91 +258,41 @@ public final class HijrahChronology extends AbstractChronology implements Serial * Computed by {@link #createEpochMonths}. */ private transient int maxYearLength; - /** - * A reference to the properties stored in - * ${java.home}/lib/calendars.properties - */ - private final transient static Properties calendarProperties; /** - * Prefix of property names for Hijrah calendar variants. + * Prefix of resource names for Hijrah calendar variants. */ - private static final String PROP_PREFIX = "calendar.hijrah."; - /** - * Suffix of property names containing the calendar type of a variant. - */ - private static final String PROP_TYPE_SUFFIX = ".type"; + private static final String RESOURCE_PREFIX = "hijrah-config-"; /** - * Static initialization of the predefined calendars found in the - * lib/calendars.properties file. + * Suffix of resource names for Hijrah calendar variants. + */ + private static final String RESOURCE_SUFFIX = ".properties"; + + /** + * Static initialization of the built-in calendars. + * The data is not loaded until it is used. */ static { - try { - calendarProperties = sun.util.calendar.BaseCalendar.getCalendarProperties(); - } catch (IOException ioe) { - throw new InternalError("Can't initialize lib/calendars.properties", ioe); - } - - try { - INSTANCE = new HijrahChronology("Hijrah-umalqura"); - // Register it by its aliases - AbstractChronology.registerChrono(INSTANCE, "Hijrah"); - AbstractChronology.registerChrono(INSTANCE, "islamic"); - } catch (DateTimeException ex) { - // Absence of Hijrah calendar is fatal to initializing this class. - PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); - logger.severe("Unable to initialize Hijrah calendar: Hijrah-umalqura", ex); - throw new RuntimeException("Unable to initialize Hijrah-umalqura calendar", ex.getCause()); - } - registerVariants(); + INSTANCE = new HijrahChronology("Hijrah-umalqura", "islamic-umalqura"); + // Register it by its aliases + AbstractChronology.registerChrono(INSTANCE, "Hijrah"); + AbstractChronology.registerChrono(INSTANCE, "islamic"); } /** - * For each Hijrah variant listed, create the HijrahChronology and register it. - * Exceptions during initialization are logged but otherwise ignored. - */ - private static void registerVariants() { - for (String name : calendarProperties.stringPropertyNames()) { - if (name.startsWith(PROP_PREFIX)) { - String id = name.substring(PROP_PREFIX.length()); - if (id.indexOf('.') >= 0) { - continue; // no name or not a simple name of a calendar - } - if (id.equals(INSTANCE.getId())) { - continue; // do not duplicate the default - } - try { - // Create and register the variant - HijrahChronology chrono = new HijrahChronology(id); - AbstractChronology.registerChrono(chrono); - } catch (DateTimeException ex) { - // Log error and continue - PlatformLogger logger = PlatformLogger.getLogger("java.time.chrono"); - logger.severe("Unable to initialize Hijrah calendar: " + id, ex); - } - } - } - } - - /** - * Create a HijrahChronology for the named variant. - * The resource and calendar type are retrieved from properties - * in the {@code calendars.properties}. - * The property names are {@code "calendar.hijrah." + id} - * and {@code "calendar.hijrah." + id + ".type"} + * Create a HijrahChronology for the named variant and type. + * * @param id the id of the calendar - * @throws DateTimeException if the calendar type is missing from the properties file. - * @throws IllegalArgumentException if the id is empty + * @param calType the typeId of the calendar + * @throws IllegalArgumentException if the id or typeId is empty */ - private HijrahChronology(String id) throws DateTimeException { + private HijrahChronology(String id, String calType) { if (id.isEmpty()) { throw new IllegalArgumentException("calendar id is empty"); } - String propName = PROP_PREFIX + id + PROP_TYPE_SUFFIX; - String calType = calendarProperties.getProperty(propName); - if (calType == null || calType.isEmpty()) { - throw new DateTimeException("calendarType is missing or empty for: " + propName); + if (calType.isEmpty()) { + throw new IllegalArgumentException("calendar typeId is empty"); } this.typeId = id; this.calendarType = calType; @@ -866,30 +795,26 @@ public final class HijrahChronology extends AbstractChronology implements Serial /** * Return the configuration properties from the resource. *
- * The default location of the variant configuration resource is: + * The location of the variant configuration resource is: *
- * "$java.home/lib/" + resource-name + * "/java/time/chrono/hijrah-config-" + calendarType + ".properties" ** - * @param resource the name of the calendar property resource + * @param calendarType the calendarType of the calendar variant * @return a Properties containing the properties read from the resource. * @throws Exception if access to the property resource fails */ - private static Properties readConfigProperties(final String resource) throws Exception { - try { - return AccessController - .doPrivileged((java.security.PrivilegedExceptionAction