Skip to content

Fix #1243: getShortWeekdays() now uses English keys after localization#5105

Merged
shai-almog merged 1 commit into
masterfrom
fix-1243-date-format-symbols-short-weekdays
May 30, 2026
Merged

Fix #1243: getShortWeekdays() now uses English keys after localization#5105
shai-almog merged 1 commit into
masterfrom
fix-1243-date-format-symbols-short-weekdays

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Closes the oldest open issue in the tracker: #1243, filed 2014-12-28 (originally code.google.com/p/codenameone/issues/detail?id=1244, migrated to GitHub on 2015-03-27).
  • DateFormatSymbols.getShortWeekdays() was looking up resource-bundle keys by the localized long name instead of by the documented English-key constant. With a Dutch bundle of WEEKDAY_LONGNAME_MONDAY=maandag + WEEKDAY_SHORTNAME_MONDAY=ma, getShortWeekdays() returned "maa" (the first three characters of the long name) instead of "ma".
  • One-line fix in com.codename1.l10n.DateFormatSymbols: pass the English WEEKDAYS array to createShortforms — exactly the way getShortMonths() already passes MONTHS. The reporter pinpointed this fix in the original issue body.
  • Same fix applied to the two sibling JDK-API copies under Ports/CLDC11/src/java/text/DateFormatSymbols.java and vm/JavaAPI/src/java/text/DateFormatSymbols.java so behaviour is consistent across the core framework, the J2ME-style port and the ParparVM Java API.
  • Adds maven/core-unittests/.../DateFormatSymbolsTest.java with three cases:
    1. getShortWeekdaysUsesEnglishKeyAfterLocalization — the original 2014 repro from getShortWeekdays() in DateFormatSymbols localize the localized 'long week names' #1243. Fails on master with expected: <ma> but was: <maa>.
    2. getWeekdaysReturnsLocalizedLongNames — sanity check that the long-name path is untouched.
    3. getShortWeekdaysFallsBackToEnglishPrefixWhenShortKeyMissing — the no-shortname-key fallback now returns "Mon" (the English prefix) instead of "maa" (the localized prefix), matching what getShortMonths() has always done for months.

Test plan

  • mvn -pl core-unittests -Dtest=DateFormatSymbolsTest test — 3/3 pass after the fix; before the fix, 2/3 failed with the exact symptoms the 2014 reporter described.
  • mvn -pl core-unittests -Dtest='SimpleDateFormatTest,DateFormatPatternsTest,SimpleDateFormatTestTest,DateFormatTest2772PortTest,DateFormatSymbolsTest' test — all 17 date-related tests still green, no regressions.
  • CI verification.

Behaviour change for consumers without a resource bundle

When no resource bundle is set, getShortWeekdays() now returns ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] (the prefix of the English long name). This matches the existing getShortMonths() behaviour and the JDK's own US-English defaults. It is the same string that the buggy code already produced for an English bundle, so apps relying on the English defaults are unaffected. Apps that have been observing the old buggy behaviour for a non-English bundle (truncated localized long names) will now correctly resolve their WEEKDAY_SHORTNAME_* keys.

🤖 Generated with Claude Code

…days (#1243)

DateFormatSymbols.getShortWeekdays() passed the already-localized
getWeekdays() array to createShortforms(), so the resource-bundle
lookup used keys derived from the localized long name (e.g.
WEEKDAY_SHORTNAME_MAANDAG) instead of the documented English key
WEEKDAY_SHORTNAME_MONDAY. With a Dutch bundle containing
WEEKDAY_LONGNAME_MONDAY=maandag and WEEKDAY_SHORTNAME_MONDAY=ma,
getShortWeekdays() returned "maa" (the first three characters of the
long name) instead of "ma".

Switch to the English WEEKDAYS array, mirroring how getShortMonths()
already handles months. This makes the WEEKDAY_SHORTNAME_<EnglishDay>
keys actually resolve, and aligns the no-bundle fallback ("Mon", "Tue",
...) with the no-bundle fallback for months.

Fixed in all three DateFormatSymbols copies — the user-facing
com.codename1.l10n one and the JDK-API-compatible copies under
Ports/CLDC11 and vm/JavaAPI — so behaviour is consistent across the
core framework, the J2ME-style port and the ParparVM Java API.

Adds maven/core-unittests/.../DateFormatSymbolsTest.java covering the
localized-key, localized-long-name, and no-short-key fallback paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Cloudflare Preview

@github-actions
Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 47 screenshots: 47 matched.
✅ JavaScript-port screenshot tests passed.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.

Native Android coverage

  • 📊 Line coverage: 12.80% (7451/58229 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.41% (37334/358503), branch 4.31% (1460/33874), complexity 5.40% (1759/32544), method 9.44% (1440/15249), class 15.52% (330/2126)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 12.80% (7451/58229 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.41% (37334/358503), branch 4.31% (1460/33874), complexity 5.40% (1759/32544), method 9.44% (1440/15249), class 15.52% (330/2126)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 829.000 ms
Base64 CN1 encode 171.000 ms
Base64 encode ratio (CN1/native) 0.206x (79.4% faster)
Base64 native decode 860.000 ms
Base64 CN1 decode 268.000 ms
Base64 decode ratio (CN1/native) 0.312x (68.8% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 209 seconds

Build and Run Timing

Metric Duration
Simulator Boot 90000 ms
Simulator Boot (Run) 1000 ms
App Install 17000 ms
App Launch 8000 ms
Test Execution 365000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 645.000 ms
Base64 CN1 encode 1273.000 ms
Base64 encode ratio (CN1/native) 1.974x (97.4% slower)
Base64 native decode 361.000 ms
Base64 CN1 decode 1150.000 ms
Base64 decode ratio (CN1/native) 3.186x (218.6% slower)
Base64 SIMD encode 498.000 ms
Base64 encode ratio (SIMD/native) 0.772x (22.8% faster)
Base64 encode ratio (SIMD/CN1) 0.391x (60.9% faster)
Base64 SIMD decode 568.000 ms
Base64 decode ratio (SIMD/native) 1.573x (57.3% slower)
Base64 decode ratio (SIMD/CN1) 0.494x (50.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 65.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.154x (84.6% faster)
Image applyMask (SIMD off) 185.000 ms
Image applyMask (SIMD on) 70.000 ms
Image applyMask ratio (SIMD on/off) 0.378x (62.2% faster)
Image modifyAlpha (SIMD off) 157.000 ms
Image modifyAlpha (SIMD on) 103.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.656x (34.4% faster)
Image modifyAlpha removeColor (SIMD off) 170.000 ms
Image modifyAlpha removeColor (SIMD on) 86.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.506x (49.4% faster)
Image PNG encode (SIMD off) 2993.000 ms
Image PNG encode (SIMD on) 964.000 ms
Image PNG encode ratio (SIMD on/off) 0.322x (67.8% faster)
Image JPEG encode 456.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.
✅ Native iOS Metal screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 332 seconds

Build and Run Timing

Metric Duration
Simulator Boot 85000 ms
Simulator Boot (Run) 0 ms
App Install 13000 ms
App Launch 7000 ms
Test Execution 299000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 519.000 ms
Base64 CN1 encode 2000.000 ms
Base64 encode ratio (CN1/native) 3.854x (285.4% slower)
Base64 native decode 510.000 ms
Base64 CN1 decode 1170.000 ms
Base64 decode ratio (CN1/native) 2.294x (129.4% slower)
Base64 SIMD encode 652.000 ms
Base64 encode ratio (SIMD/native) 1.256x (25.6% slower)
Base64 encode ratio (SIMD/CN1) 0.326x (67.4% faster)
Base64 SIMD decode 406.000 ms
Base64 decode ratio (SIMD/native) 0.796x (20.4% faster)
Base64 decode ratio (SIMD/CN1) 0.347x (65.3% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 61.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.148x (85.2% faster)
Image applyMask (SIMD off) 125.000 ms
Image applyMask (SIMD on) 89.000 ms
Image applyMask ratio (SIMD on/off) 0.712x (28.8% faster)
Image modifyAlpha (SIMD off) 154.000 ms
Image modifyAlpha (SIMD on) 152.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.987x (1.3% faster)
Image modifyAlpha removeColor (SIMD off) 188.000 ms
Image modifyAlpha removeColor (SIMD on) 91.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.484x (51.6% faster)
Image PNG encode (SIMD off) 1387.000 ms
Image PNG encode (SIMD on) 1096.000 ms
Image PNG encode ratio (SIMD on/off) 0.790x (21.0% faster)
Image JPEG encode 624.000 ms

@github-actions
Copy link
Copy Markdown
Contributor

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 715 total, 0 failed, 3 skipped

Benchmark Results

  • Execution Time: 9044 ms

  • Hotspots (Top 20 sampled methods):

    • 24.51% java.lang.String.indexOf (379 samples)
    • 21.93% com.codename1.tools.translator.Parser.isMethodUsed (339 samples)
    • 5.95% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (92 samples)
    • 5.89% com.codename1.tools.translator.Parser.addToConstantPool (91 samples)
    • 5.76% java.util.ArrayList.indexOf (89 samples)
    • 4.53% java.lang.Object.hashCode (70 samples)
    • 2.72% java.lang.System.identityHashCode (42 samples)
    • 2.33% com.codename1.tools.translator.ByteCodeClass.markDependent (36 samples)
    • 2.01% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (31 samples)
    • 1.81% com.codename1.tools.translator.ByteCodeClass.updateAllDependencies (28 samples)
    • 1.68% com.codename1.tools.translator.BytecodeMethod.appendMethodSignatureSuffixFromDesc (26 samples)
    • 1.68% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (26 samples)
    • 1.23% java.lang.StringBuilder.append (19 samples)
    • 0.91% com.codename1.tools.translator.Parser.cullMethods (14 samples)
    • 0.84% com.codename1.tools.translator.BytecodeMethod.optimize (13 samples)
    • 0.84% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (13 samples)
    • 0.78% sun.nio.fs.UnixNativeDispatcher.open0 (12 samples)
    • 0.71% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (11 samples)
    • 0.65% com.codename1.tools.translator.Parser.getClassByName (10 samples)
    • 0.52% java.io.UnixFileSystem.getBooleanAttributes0 (8 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@shai-almog shai-almog merged commit defe5ed into master May 30, 2026
25 checks passed
@shai-almog shai-almog deleted the fix-1243-date-format-symbols-short-weekdays branch May 30, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant