Skip to content

Commit 89b85a8

Browse files
committed
7102969: currency.properties supercede not working correctly
8157138: Error while fetching currency instance by Currency.getInstance(currencycode) Reviewed-by: andrew Backport-of: 93f4f6c1b50c17bf713a2cfa806e64a8d73d6770
1 parent 1b94cbf commit 89b85a8

File tree

7 files changed

+347
-100
lines changed

7 files changed

+347
-100
lines changed

jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public class GenerateCurrencyData {
120120

121121
private static final int maxOtherCurrencies = 128;
122122
private static int otherCurrenciesCount = 0;
123-
private static StringBuffer otherCurrencies = new StringBuffer();
123+
private static String[] otherCurrencies = new String[maxOtherCurrencies];
124124
private static int[] otherCurrenciesDefaultFractionDigits = new int[maxOtherCurrencies];
125125
private static int[] otherCurrenciesNumericCode= new int[maxOtherCurrencies];
126126

@@ -323,10 +323,7 @@ private static void buildOtherTables() {
323323
if (otherCurrenciesCount == maxOtherCurrencies) {
324324
throw new RuntimeException("too many other currencies");
325325
}
326-
if (otherCurrencies.length() > 0) {
327-
otherCurrencies.append('-');
328-
}
329-
otherCurrencies.append(currencyCode);
326+
otherCurrencies[otherCurrenciesCount] = currencyCode;
330327
otherCurrenciesDefaultFractionDigits[otherCurrenciesCount] = getDefaultFractionDigits(currencyCode);
331328
otherCurrenciesNumericCode[otherCurrenciesCount] = getNumericCode(currencyCode);
332329
otherCurrenciesCount++;
@@ -355,35 +352,41 @@ private static void writeOutput() throws IOException {
355352
out.writeInt(Integer.parseInt(dataVersion));
356353
writeIntArray(mainTable, mainTable.length);
357354
out.writeInt(specialCaseCount);
358-
writeLongArray(specialCaseCutOverTimes, specialCaseCount);
359-
writeStringArray(specialCaseOldCurrencies, specialCaseCount);
360-
writeStringArray(specialCaseNewCurrencies, specialCaseCount);
361-
writeIntArray(specialCaseOldCurrenciesDefaultFractionDigits, specialCaseCount);
362-
writeIntArray(specialCaseNewCurrenciesDefaultFractionDigits, specialCaseCount);
363-
writeIntArray(specialCaseOldCurrenciesNumericCode, specialCaseCount);
364-
writeIntArray(specialCaseNewCurrenciesNumericCode, specialCaseCount);
355+
writeSpecialCaseEntries();
365356
out.writeInt(otherCurrenciesCount);
366-
out.writeUTF(otherCurrencies.toString());
367-
writeIntArray(otherCurrenciesDefaultFractionDigits, otherCurrenciesCount);
368-
writeIntArray(otherCurrenciesNumericCode, otherCurrenciesCount);
357+
writeOtherCurrencies();
369358
}
370359

371360
private static void writeIntArray(int[] ia, int count) throws IOException {
372-
for (int i = 0; i < count; i ++) {
361+
for (int i = 0; i < count; i++) {
373362
out.writeInt(ia[i]);
374363
}
375364
}
376365

377-
private static void writeLongArray(long[] la, int count) throws IOException {
378-
for (int i = 0; i < count; i ++) {
379-
out.writeLong(la[i]);
366+
private static void writeSpecialCaseEntries() throws IOException {
367+
for (int index = 0; index < specialCaseCount; index++) {
368+
out.writeLong(specialCaseCutOverTimes[index]);
369+
String str = (specialCaseOldCurrencies[index] != null)
370+
? specialCaseOldCurrencies[index] : "";
371+
out.writeUTF(str);
372+
str = (specialCaseNewCurrencies[index] != null)
373+
? specialCaseNewCurrencies[index] : "";
374+
out.writeUTF(str);
375+
out.writeInt(specialCaseOldCurrenciesDefaultFractionDigits[index]);
376+
out.writeInt(specialCaseNewCurrenciesDefaultFractionDigits[index]);
377+
out.writeInt(specialCaseOldCurrenciesNumericCode[index]);
378+
out.writeInt(specialCaseNewCurrenciesNumericCode[index]);
380379
}
381380
}
382381

383-
private static void writeStringArray(String[] sa, int count) throws IOException {
384-
for (int i = 0; i < count; i ++) {
385-
String str = (sa[i] != null) ? sa[i] : "";
382+
private static void writeOtherCurrencies() throws IOException {
383+
for (int index = 0; index < otherCurrenciesCount; index++) {
384+
String str = (otherCurrencies[index] != null)
385+
? otherCurrencies[index] : "";
386386
out.writeUTF(str);
387+
out.writeInt(otherCurrenciesDefaultFractionDigits[index]);
388+
out.writeInt(otherCurrenciesNumericCode[index]);
387389
}
388390
}
391+
389392
}

0 commit comments

Comments
 (0)