diff --git a/teavm-classlib/pom.xml b/teavm-classlib/pom.xml index f6fc23a7a..7497b4015 100644 --- a/teavm-classlib/pom.xml +++ b/teavm-classlib/pom.xml @@ -100,6 +100,7 @@ java.lang.reflect java.io java.net + java.text java.util java.util.logging java.util.concurrent diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/CLDRReader.java b/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/CLDRReader.java index 38646c7e7..73aa6a565 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/CLDRReader.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/impl/unicode/CLDRReader.java @@ -38,10 +38,21 @@ public class CLDRReader { private Set availableLocales = new LinkedHashSet<>(); private Set availableLanguages = new LinkedHashSet<>(); private Set availableCountries = new LinkedHashSet<>(); + private boolean initialized; + private Properties properties; + private ClassLoader classLoader; public CLDRReader(Properties properties, ClassLoader classLoader) { - findAvailableLocales(properties); - readCLDR(classLoader); + this.properties = properties; + this.classLoader = classLoader; + } + + private synchronized void ensureInitialized() { + if (!initialized) { + initialized = true; + findAvailableLocales(properties); + readCLDR(classLoader); + } } private void findAvailableLocales(Properties properties) { @@ -278,30 +289,37 @@ public class CLDRReader { } public Map getKnownLocales() { + ensureInitialized(); return Collections.unmodifiableMap(knownLocales); } public Set getAvailableLocales() { + ensureInitialized(); return Collections.unmodifiableSet(availableLocales); } public Set getAvailableLanguages() { + ensureInitialized(); return Collections.unmodifiableSet(availableLanguages); } public Set getAvailableCountries() { + ensureInitialized(); return Collections.unmodifiableSet(availableCountries); } public Map getMinDaysMap() { + ensureInitialized(); return Collections.unmodifiableMap(minDaysMap); } public Map getFirstDayMap() { + ensureInitialized(); return Collections.unmodifiableMap(firstDayMap); } public Map getLikelySubtags() { + ensureInitialized(); return Collections.unmodifiableMap(likelySubtags); } }