Skip to content

Fix the iOS String.format crash and the toString it relied on (issue #5482) - #5510

Open
shai-almog wants to merge 12 commits into
masterfrom
fix-5482-string-format-ios-crash
Open

Fix the iOS String.format crash and the toString it relied on (issue #5482)#5510
shai-almog wants to merge 12 commits into
masterfrom
fix-5482-string-format-ios-crash

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Fixes #5482.

The crash

String.format was a native method. Its Objective-C branch formatted a string, threw it away, and returned fromNSString([NSString init]) -- sending init to the NSString class object:

NSString* result = [[[NSString alloc] initWithFormat:toNSString(...) arguments:argList] autorelease];
free(argList);
JAVA_OBJECT out = fromNSString(CN1_THREAD_STATE_PASS_ARG [NSString init]);

That aborts the process with +[NSString<0x...> init]: cannot init a class object, which is exactly the termination the reporter pasted. Every String.format call on iOS killed the app.

The C fallback used everywhere else did not crash, but ignored width and precision entirely, so "%.3f" printed every digit of the double and "%.2e" printed %. followed by the whole number and a literal 2e.

Neither was caught because the Apple branch is behind #if defined(__APPLE__) && defined(__OBJC__) and parparvm-tests runs on ubuntu-latest, so CI only ever compiled the #else branch.

The fix

Formatting is string manipulation, so the native is gone and the work happens once in java.lang.StringFormatter. A single implementation now serves iOS, the JavaScript target and the C fallback -- which also means the Linux CI test is finally meaningful for iOS.

Supported: s S b B h H c C d o x X e E f g G n %, the - + ' ' 0 , ( # flags, width, precision, and the %n$ / %< argument selectors. Rendering is locale independent.

%a (hexadecimal float) and %t (date and time) are not implemented; they raise UnknownFormatConversionException rather than producing something wrong. Both are documented in the class javadoc and pinned by the test.

A malformed format string now raises the java.util exception the JVM raises -- the ten missing exception classes are added here -- instead of taking the process down. That was the reporter's closing request: "it should have been a trapped error, presented as some kind of a runtime fault, rather than a hard crash."

Two further defects the new test exposed

Once the output could be diffed against a JVM, two unrelated ParparVM bugs failed the test:

  • Double.toString / Float.toString were badly non-conforming. They asked snprintf for a fixed "%f" (six decimals) in the plain range and "%1.20E" (twenty-one significant digits) in the scientific range. 1.0/3.0 rendered as "0.333333" instead of "0.3333333333333333"; 1e30 rendered as "1.00000000000000001988E30" instead of "1.0E30". This hit every concatenation of a double on iOS, not just formatting. Replaced with a binary search for the shortest rendering that round trips, which is what the specification asks for.
  • Math.abs(-0.0) returned -0.0, because a < 0 is false for negative zero. Now fabs/fabsf.

The reporter's other suspicion

He also suspected getClass() was returning null. It is not: getClassImpl cannot return null for a non-null receiver -- it hands back &ClazzClazz when the class reference is absent. GetClassIntegrationTest reproduces his exact shape (interface-typed reference, getClass() used as a HashMap key, the "class is " + cl concatenation that printed null) and re-checks every invariant across 200k allocations of churn. Class identity, hashing, string conversion and map lookup all match the JVM. That symptom was downstream of the process already being wrecked.

Coverage

StringFormatIntegrationTest and GetClassIntegrationTest run the same program on a real JVM and under ParparVM and diff it case by case, so the expectations are the JDK's rather than hand written. On macOS the harness compiles nativeMethods.m as Objective-C, so these exercise the branch that was crashing.

Off-line, the implementation was diffed against the JDK over:

sweep cases divergences
curated + generated conversions, flags, widths, precisions 384,089 0
randomly assembled format strings and argument lists 300,000 0 (excluding the documented %a / %t gap)
random double and float bit patterns through toString 399,110 0 vs JDK 21/25

JDK 11 and 17 differ from the last row on ~5.6% of random doubles because they predate JDK-4511638; the values used in the committed test are byte-identical across JDK 11, 17 and 25.

Full ParparVM suite: 411 tests, 0 failures.

cd vm && mvn -B test -pl tests -am -DexcludedGroups=benchmark

🤖 Generated with Claude Code

…5482)

String.format was a native method whose Objective-C branch formatted a string,
threw it away, and returned fromNSString([NSString init]) -- sending init to the
NSString class object, which aborts the process with
"+[NSString<0x...> init]: cannot init a class object". Every String.format call
on iOS killed the app. The C fallback that ran everywhere else did not crash but
ignored width and precision, so "%.3f" printed every digit of the double.

The Apple branch sits behind #if defined(__APPLE__) && defined(__OBJC__) and
parparvm-tests runs on ubuntu-latest, so CI only ever compiled the #else branch
and nothing flagged either problem.

Formatting is string manipulation, so drop the native entirely and implement it
once in java.lang.StringFormatter. One implementation now serves iOS, the
JavaScript target and the C fallback, which also makes the Linux CI test
meaningful for iOS. Supported conversions are s S b B h H c C d o x X e E f g G
n %, with the - + ' ' 0 , ( # flags, width, precision and the %n$ / %< argument
selectors. %a (hexadecimal float) and %t (date and time) are not implemented and
raise UnknownFormatConversionException rather than producing something wrong.

A malformed format string now raises the java.util exception the JVM raises
(the ten missing classes are added here) instead of taking the process down,
which is what the reporter asked for.

Two further defects surfaced once the output could be compared with a JVM:

- Double.toString and Float.toString were badly non-conforming. They asked
  snprintf for a fixed "%f" (six decimals) in the plain range and "%1.20E"
  (twenty-one significant digits) in the scientific range, so 1.0/3.0 rendered
  as "0.333333" instead of "0.3333333333333333" and 1e30 rendered as
  "1.00000000000000001988E30" instead of "1.0E30". That affected every
  concatenation of a double, not just formatting. Replaced with a search for the
  shortest rendering that round trips, which is what the specification asks for.

- Math.abs(-0.0) returned -0.0, because "a < 0" is false for negative zero.
  Now fabs/fabsf.

Coverage: StringFormatIntegrationTest and GetClassIntegrationTest run the same
program on a real JVM and under ParparVM and diff it case by case, so the
expectations are the JDK's rather than hand written. On macOS the harness
compiles nativeMethods.m as Objective-C, so these exercise the branch that was
crashing. Off-line, the implementation was diffed against the JDK over 384k
value cases, 300k randomly assembled format strings and 399k random double and
float bit patterns with no divergence.

GetClassIntegrationTest also covers the reporter's other suspicion, that
getClass() was returning null. It does not: getClassImpl cannot return null for
a non-null receiver, and Class identity, hashing, string conversion and use as a
HashMap key all match the JVM under allocation churn. The test pins that.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 2, 2026 08:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The new formatter has a confirmed edge-case bug for explicit argument index 0$ handling and there is a public JavaAPI compatibility issue in IllegalFormatException constructor visibility.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR fixes the iOS hard-crash in String.format() (issue #5482) by removing the native implementation and replacing it with a shared Java formatter (java.lang.StringFormatter) that is exercised by new differential integration tests. It also corrects ParparVM’s Double.toString/Float.toString conformance and fixes Math.abs(-0.0) to match JVM behavior.

Changes:

  • Replace native String.format() with a Java implementation (StringFormatter) used across targets (iOS/JS/C fallback).
  • Fix ParparVM floating-to-string rendering to produce the shortest round-tripping decimal and correct Math.abs() for negative zero.
  • Add differential integration tests (JVM vs ParparVM) for String.format() output and getClass()/Class behavior under allocation churn.
File summaries
File Description
vm/tests/src/test/resources/com/codename1/tools/translator/StringFormatApp.java Test program emitting per-case String.format() results for line-by-line diffing.
vm/tests/src/test/resources/com/codename1/tools/translator/GetClassApp.java Test program pinning getClass() and Class identity/hash/toString under churn.
vm/tests/src/test/java/com/codename1/tools/translator/StringFormatIntegrationTest.java Differential JVM vs ParparVM integration test for formatting output and unsupported conversions.
vm/tests/src/test/java/com/codename1/tools/translator/GetClassIntegrationTest.java Differential JVM vs ParparVM integration test for getClass() and Class map-key behavior.
vm/JavaAPI/src/java/util/UnknownFormatConversionException.java Adds missing java.util exception used by formatter error paths.
vm/JavaAPI/src/java/util/MissingFormatWidthException.java Adds missing java.util exception used by formatter width validation.
vm/JavaAPI/src/java/util/MissingFormatArgumentException.java Adds missing java.util exception used for missing args/indexes.
vm/JavaAPI/src/java/util/IllegalFormatWidthException.java Adds missing java.util exception used for illegal width handling.
vm/JavaAPI/src/java/util/IllegalFormatPrecisionException.java Adds missing java.util exception used for illegal precision handling.
vm/JavaAPI/src/java/util/IllegalFormatFlagsException.java Adds missing java.util exception used for illegal flag combinations.
vm/JavaAPI/src/java/util/IllegalFormatException.java Adds missing java.util base exception type for formatter-related unchecked errors.
vm/JavaAPI/src/java/util/IllegalFormatConversionException.java Adds missing java.util exception used for wrong argument type per conversion.
vm/JavaAPI/src/java/util/IllegalFormatCodePointException.java Adds missing java.util exception for invalid code points in %c/%C.
vm/JavaAPI/src/java/util/FormatFlagsConversionMismatchException.java Adds missing java.util exception for flag/conversion mismatches.
vm/JavaAPI/src/java/util/DuplicateFormatFlagsException.java Adds missing java.util exception for duplicated flags.
vm/JavaAPI/src/java/lang/StringFormatter.java New shared Java implementation of String.format() logic (parsing, conversions, rounding).
vm/JavaAPI/src/java/lang/String.java Switches String.format() from native to StringFormatter.format().
vm/ByteCodeTranslator/src/nativeMethods.m Fixes Double.toString/Float.toString conformance and Math.abs() negative-zero behavior; removes native String.format.
vm/ByteCodeTranslator/src/javascript/parparvm_runtime.js Removes JavaScript native String.format() binding (now handled in Java).
vm/ByteCodeTranslator/src/com/codename1/tools/translator/JavascriptNativeRegistry.java Removes String.format from JS native registry list.
Review details
  • Files reviewed: 20/20 changed files
  • Comments generated: 2
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread vm/JavaAPI/src/java/lang/StringFormatter.java Outdated
Comment thread vm/JavaAPI/src/java/util/IllegalFormatException.java

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d24938b462

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vm/JavaAPI/src/java/lang/StringFormatter.java
Comment thread vm/JavaAPI/src/java/lang/StringFormatter.java Outdated
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 420 total, 0 failed, 14 skipped

Benchmark Results

  • Execution Time: 20806 ms

  • Hotspots (Top 20 sampled methods):

    • 19.29% java.util.ArrayList.indexOf (342 samples)
    • 8.52% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (151 samples)
    • 3.89% java.lang.StringBuilder.append (69 samples)
    • 3.50% com.codename1.tools.translator.ByteCodeClass.hasDeclaredMethod (62 samples)
    • 3.33% com.codename1.tools.translator.BytecodeMethod.optimize (59 samples)
    • 3.10% com.codename1.tools.translator.Parser.cn1EnsureSubclassIndex (55 samples)
    • 2.71% org.objectweb.asm.tree.analysis.Analyzer.analyze (48 samples)
    • 2.20% org.objectweb.asm.tree.analysis.Analyzer.findSubroutine (39 samples)
    • 1.80% com.codename1.tools.translator.Parser.classIndex (32 samples)
    • 1.75% com.codename1.tools.translator.bytecodes.Invoke.resolveDirectTarget (31 samples)
    • 1.58% java.util.HashMap.hash (28 samples)
    • 1.52% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (27 samples)
    • 1.52% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (27 samples)
    • 1.47% org.objectweb.asm.ClassReader.readCode (26 samples)
    • 1.35% com.codename1.tools.translator.BytecodeMethod.equals (24 samples)
    • 1.24% com.codename1.tools.translator.ByteCodeClass.markDependent (22 samples)
    • 1.18% java.lang.StringCoding.encode (21 samples)
    • 1.02% com.codename1.tools.translator.bytecodes.Invoke.findMethodUp (18 samples)
    • 0.96% java.lang.Object.hashCode (17 samples)
    • 0.90% java.util.IdentityHashMap$KeySet.toArray (16 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.

@github-actions

github-actions Bot commented Aug 2, 2026

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.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 matched.
Native Windows port, REAL shipping pipeline: the hellocodenameone screenshot suite rendered by a binary CROSS-COMPILED on Linux (clang-cl + xwin, WebView2 linked) and RUN on a Windows x64 runner. Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 61ms / native 6ms = 10.1x speedup
SIMD float-mul (64K x300) java 66ms / native 4ms = 16.5x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 187.000 ms
Base64 CN1 decode 126.000 ms
Base64 SIMD encode 100.000 ms
Base64 encode ratio (SIMD/CN1) 0.535x (46.5% faster)
Base64 SIMD decode 90.000 ms
Base64 decode ratio (SIMD/CN1) 0.714x (28.6% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 39.000 ms
Image createMask (SIMD on) 18.000 ms
Image createMask ratio (SIMD on/off) 0.462x (53.8% faster)
Image applyMask (SIMD off) 45.000 ms
Image applyMask (SIMD on) 38.000 ms
Image applyMask ratio (SIMD on/off) 0.844x (15.6% faster)
Image modifyAlpha (SIMD off) 43.000 ms
Image modifyAlpha (SIMD on) 33.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.767x (23.3% faster)
Image modifyAlpha removeColor (SIMD off) 51.000 ms
Image modifyAlpha removeColor (SIMD on) 63.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.235x (23.5% slower)

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 matched.
Native Windows port (x64 / Intel-AMD): full hellocodenameone screenshot suite rendered offscreen with Direct2D/DirectWrite, plus the real benchmarks (base64 native/CN1/SIMD, image createMask/applyMask/modifyAlpha/PNG/JPEG, SSE2 SIMD kernels). Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 64ms / native 5ms = 12.8x speedup
SIMD float-mul (64K x300) java 70ms / native 4ms = 17.5x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 205.000 ms
Base64 CN1 decode 136.000 ms
Base64 SIMD encode 106.000 ms
Base64 encode ratio (SIMD/CN1) 0.517x (48.3% faster)
Base64 SIMD decode 103.000 ms
Base64 decode ratio (SIMD/CN1) 0.757x (24.3% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 29.000 ms
Image createMask (SIMD on) 131.000 ms
Image createMask ratio (SIMD on/off) 4.517x (351.7% slower)
Image applyMask (SIMD off) 73.000 ms
Image applyMask (SIMD on) 67.000 ms
Image applyMask ratio (SIMD on/off) 0.918x (8.2% faster)
Image modifyAlpha (SIMD off) 73.000 ms
Image modifyAlpha (SIMD on) 61.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.836x (16.4% faster)
Image modifyAlpha removeColor (SIMD off) 81.000 ms
Image modifyAlpha removeColor (SIMD on) 70.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.864x (13.6% faster)

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 147 screenshots: 147 matched.
Native Linux port (x64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub x64 runner. Baseline: scripts/linux/screenshots.

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 147 screenshots: 147 matched.
Native Linux port (arm64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub arm64 runner. Baseline: scripts/linux/screenshots-arm.

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 matched.
Native Windows port (arm64 / Apple Silicon - Arm): full hellocodenameone screenshot suite rendered offscreen with Direct2D/DirectWrite, plus the real benchmarks (base64 native/CN1/SIMD, image createMask/applyMask/modifyAlpha/PNG/JPEG, NEON SIMD kernels). Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 56ms / native 3ms = 18.6x speedup
SIMD float-mul (64K x300) java 56ms / native 4ms = 14.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 246.000 ms
Base64 CN1 decode 128.000 ms
Base64 SIMD encode 66.000 ms
Base64 encode ratio (SIMD/CN1) 0.268x (73.2% faster)
Base64 SIMD decode 64.000 ms
Base64 decode ratio (SIMD/CN1) 0.500x (50.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 12.000 ms
Image createMask (SIMD on) 7.000 ms
Image createMask ratio (SIMD on/off) 0.583x (41.7% faster)
Image applyMask (SIMD off) 24.000 ms
Image applyMask (SIMD on) 131.000 ms
Image applyMask ratio (SIMD on/off) 5.458x (445.8% slower)
Image modifyAlpha (SIMD off) 16.000 ms
Image modifyAlpha (SIMD on) 11.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.688x (31.3% faster)
Image modifyAlpha removeColor (SIMD off) 20.000 ms
Image modifyAlpha removeColor (SIMD on) 12.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.600x (40.0% faster)

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 144 screenshots: 144 matched.
✅ Native Apple TV (tvOS, Metal) screenshot tests passed.

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 217 screenshots: 217 matched.
✅ Native Apple Watch (watchOS, Core Graphics) screenshot tests passed.

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 93000 ms
Simulator Boot (Run) 2000 ms
App Install 17000 ms
App Launch 2000 ms
Test Execution 642000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 86ms / native 3ms = 28.6x speedup
SIMD float-mul (64K x300) java 80ms / native 6ms = 13.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 504.000 ms
Base64 CN1 decode 238.000 ms
Base64 native encode 1798.000 ms
Base64 encode ratio (CN1/native) 0.280x (72.0% faster)
Base64 native decode 914.000 ms
Base64 decode ratio (CN1/native) 0.260x (74.0% faster)
Base64 SIMD encode 128.000 ms
Base64 encode ratio (SIMD/CN1) 0.254x (74.6% faster)
Base64 SIMD decode 210.000 ms
Base64 decode ratio (SIMD/CN1) 0.882x (11.8% faster)
Base64 encode ratio (SIMD/native) 0.071x (92.9% faster)
Base64 decode ratio (SIMD/native) 0.230x (77.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 12.000 ms
Image createMask (SIMD on) 13.000 ms
Image createMask ratio (SIMD on/off) 1.083x (8.3% slower)
Image applyMask (SIMD off) 366.000 ms
Image applyMask (SIMD on) 320.000 ms
Image applyMask ratio (SIMD on/off) 0.874x (12.6% faster)
Image modifyAlpha (SIMD off) 194.000 ms
Image modifyAlpha (SIMD on) 179.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.923x (7.7% faster)
Image modifyAlpha removeColor (SIMD off) 183.000 ms
Image modifyAlpha removeColor (SIMD on) 258.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.410x (41.0% slower)

…headers

Three review findings:

- "%0$s" recorded argIndex == 0, which the parser then treated as "no explicit
  index given" and satisfied from the next sequential argument. Argument indexes
  are 1-based, so this now raises IllegalFormatArgumentIndexException the way
  JDK 16 and later do. JDK 11 still accepts index zero, so the case is asserted
  against ParparVM alone rather than through the shared diff.

- A '.' with no digits after it defaulted the precision to zero, so "%.s"
  quietly produced an empty string. Every supported JDK rejects it with
  UnknownFormatConversionException naming '.' as the conversion; so do we now.

- The four new test files were missing the Codename One GPLv2 + Classpath
  Exception header, which failed check-copyright-headers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 2, 2026 10:11
@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

iOS Metal screenshot updates

Compared 149 screenshots: 148 matched, 1 updated.

  • landscape — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

    landscape
    Preview info: JPEG preview quality 70; JPEG preview quality 70; downscaled to 825x1789.
    Full-resolution PNG saved as landscape.png in workflow artifacts.

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 101000 ms
Simulator Boot (Run) 1000 ms
App Install 18000 ms
App Launch 2000 ms
Test Execution 618000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 81ms / native 4ms = 20.2x speedup
SIMD float-mul (64K x300) java 71ms / native 3ms = 23.6x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 1595.000 ms
Base64 CN1 decode 300.000 ms
Base64 native encode 2190.000 ms
Base64 encode ratio (CN1/native) 0.728x (27.2% faster)
Base64 native decode 2463.000 ms
Base64 decode ratio (CN1/native) 0.122x (87.8% faster)
Base64 SIMD encode 61.000 ms
Base64 encode ratio (SIMD/CN1) 0.038x (96.2% faster)
Base64 SIMD decode 62.000 ms
Base64 decode ratio (SIMD/CN1) 0.207x (79.3% faster)
Base64 encode ratio (SIMD/native) 0.028x (97.2% faster)
Base64 decode ratio (SIMD/native) 0.025x (97.5% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 12.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.167x (83.3% faster)
Image applyMask (SIMD off) 94.000 ms
Image applyMask (SIMD on) 107.000 ms
Image applyMask ratio (SIMD on/off) 1.138x (13.8% slower)
Image modifyAlpha (SIMD off) 241.000 ms
Image modifyAlpha (SIMD on) 640.000 ms
Image modifyAlpha ratio (SIMD on/off) 2.656x (165.6% slower)
Image modifyAlpha removeColor (SIMD off) 221.000 ms
Image modifyAlpha removeColor (SIMD on) 173.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.783x (21.7% faster)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

There are correctness/test-stability issues in the new formatter parsing and integration test setup that should be addressed to avoid divergent behavior and flaky results.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (2)

vm/JavaAPI/src/java/lang/StringFormatter.java:154

  • The parser currently allows combining an explicit argument index (e.g. "%2$") with the previous-argument flag ('<'). That combination is not meaningful and the current logic will silently prioritize previous and ignore the explicit index (or throw MissingFormatArgumentException if it’s the first specifier), diverging from java.util.Formatter’s behavior for invalid format strings. Consider rejecting '<' when an explicit argument index was already parsed for this specifier.
                } else if (f == '<') {
                    previous = true;
                    pos++;
                    continue;

vm/tests/src/test/resources/com/codename1/tools/translator/StringFormatApp.java:244

  • This integration test derives its expected output from a JVM run of String.format(), but several cases depend on the JVM default locale (e.g. %,d, %,.2f, and %S uppercasing). Without pinning the default locale, the diff can become environment-dependent and fail on machines with non-"en_US" defaults even if ParparVM is correct. Consider setting the default locale explicitly at the start of main().
    public static void main(String[] args) {
        strings();
        integers();
        floats();
        failures();
  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@shai-almog

shai-almog commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 148 screenshots: 148 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 221ms / native 28ms = 7.8x speedup
SIMD float-mul (64K x300) java 79ms / native 5ms = 15.8x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 211.000 ms
Base64 CN1 decode 123.000 ms
Base64 native encode 822.000 ms
Base64 encode ratio (CN1/native) 0.257x (74.3% faster)
Base64 native decode 526.000 ms
Base64 decode ratio (CN1/native) 0.234x (76.6% faster)
Base64 SIMD encode 63.000 ms
Base64 encode ratio (SIMD/CN1) 0.299x (70.1% faster)
Base64 SIMD decode 53.000 ms
Base64 decode ratio (SIMD/CN1) 0.431x (56.9% faster)
Base64 encode ratio (SIMD/native) 0.077x (92.3% faster)
Base64 decode ratio (SIMD/native) 0.101x (89.9% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 7.000 ms
Image createMask (SIMD on) 4.000 ms
Image createMask ratio (SIMD on/off) 0.571x (42.9% faster)
Image applyMask (SIMD off) 70.000 ms
Image applyMask (SIMD on) 59.000 ms
Image applyMask ratio (SIMD on/off) 0.843x (15.7% faster)
Image modifyAlpha (SIMD off) 56.000 ms
Image modifyAlpha (SIMD on) 62.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.107x (10.7% slower)
Image modifyAlpha removeColor (SIMD off) 73.000 ms
Image modifyAlpha removeColor (SIMD on) 51.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.699x (30.1% faster)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e37e4b8ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vm/JavaAPI/src/java/lang/StringFormatter.java Outdated
Comment thread vm/JavaAPI/src/java/lang/StringFormatter.java Outdated
Two more review findings, both confirmed against the JDK first:

- format(fmt, (Object[]) null) is not an empty argument list. The JVM skips the
  bounds checks and hands every specifier a null, so "%s %s" renders "null null"
  where this threw MissingFormatArgumentException. "%<" is the one exception: it
  reuses the previous argument, so it still requires that one existed, which is
  what the parser fuzz caught after the first attempt made null unconditional.

- '<' was consumed outside the duplicate-flag check, so "%s %<<s" quietly
  rendered "a a" instead of raising DuplicateFormatFlagsException. It is now a
  flag bit like every other, which also makes it participate in the %% and %n
  flag validation without the special case that was there before.

Both behaviours are identical on JDK 11, 17 and 25, so the new cases go through
the shared JVM-vs-ParparVM diff rather than being asserted one-sided.

The parser sweep now also generates null argument arrays and doubled flags;
divergence is still zero apart from the documented %a and %t gap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 2, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The new differential test currently depends on the host default Locale and the public String.format() javadoc doesn’t document the locale-independent behavior, both of which can cause avoidable instability/confusion.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (2)

vm/tests/src/test/java/com/codename1/tools/translator/StringFormatIntegrationTest.java:202

  • The JVM side of this differential test depends on the host default Locale for grouping/decimal separators. Since the ParparVM implementation is documented as locale-independent (always ',' grouping and '.' decimal), this test can become flaky or fail on machines with a non-English default locale. Consider forcing a known locale for the JVM run via system properties so the expected output matches the intended locale-independent behavior consistently.
        ProcessBuilder pb = new ProcessBuilder(
                javaExe,
                "-cp",
                classesDir + System.getProperty("path.separator") + javaApiDir,
                "StringFormatApp"

vm/JavaAPI/src/java/lang/String.java:1085

  • The public String.format() javadoc here doesn’t mention that this implementation is locale-independent (fixed '.' decimal separator and ',' grouping, and %n emits '\n'), which is a behavioral difference from the JDK that callers may rely on. Since this is a public API entry point, consider documenting the locale behavior (and that unsupported conversions like %a/%t throw UnknownFormatConversionException) here rather than only in the internal StringFormatter class.
    /**
     * Returns a formatted string using the specified format string and arguments.
     * Supports the {@code s b h c d o x e f g n %} conversions (and their uppercase
     * variants) with the {@code - + ' ' 0 , ( #} flags, width, precision, and the
     * {@code %n$} / {@code %<} argument selectors.
  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

The vm/tests differential covers ParparVM's C and Objective-C target, but that
is not the path a shipping app takes: the iOS build translates the core out of
the bundled iOSPort.jar rather than out of the reactor, JavaSE and Android run
their own java.util.Formatter, and the JavaScript port runs the translated Java
through its own runtime. Those are four different code paths reaching the same
API, and nothing was asserting that they agree.

StringFormatTest runs the same 124 expectations on every port the suite covers:
iOS GL and Metal, tvOS, watchOS, Android, JavaScript, mac native, Linux, Windows
and the JavaSE simulator. It takes no screenshot; it is a pure assertion test in
the shape of the existing FloatingToStringTest.

Every expected value was produced by a real Java SE java.util.Formatter rather
than written by hand. The generator is checked in as
scripts/hellocodenameone/tools/generate-string-format-cases.java so the table can
be regenerated and audited, and it emits a byte-identical table on JDK 8, 11, 17,
21 and 25 -- so this pins behaviour that does not drift with the JDK the suite
happens to build against.

Coverage includes the conversions, flags, widths and precisions an app actually
uses, the HALF_UP rounding cases where Java disagrees with C printf, and the four
malformed-format cases found in review on this branch (empty precision, repeated
flags, grouping on hex, zero padding on a string).

Three things are deliberately excluded because they are genuinely not consistent
across these runtimes, rather than papered over:

- %a and %t, which ParparVM does not implement.
- %0$s, accepted before JDK 16 and rejected from 16 on.
- a pinned value for %n, since the JDK emits the platform line separator and that
  is "\r\n" on a Windows JVM. The test asserts it is a line separator instead.

JavaSE and Android format through the default locale, so the test probes the
platform's decimal and grouping separators rather than assuming them, and fails
with a specific message if the platform also localises the digits.

Registered in Cn1ssDeviceRunner and the java-standard-apis feature group. The
stored per-port reports get a not-run entry, which the next master publish
replaces with the real result; the pinned test count moves 170 -> 171.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 01:16

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2087fbc906

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread vm/JavaAPI/src/java/lang/StringFormatter.java Outdated
…p exhaustively

The reported case is real and JDK 11, 17 and 25 agree on it: for a character
conversion the JVM reports an unsupported flag ahead of the missing width, which
is the opposite order from every other conversion.

    "%-0c" -> FormatFlagsConversionMismatchException   (not MissingFormatWidth)
    "%-0s" -> MissingFormatWidthException
    "%-0d" -> MissingFormatWidthException
    "%-#b" -> FormatFlagsConversionMismatchException

Six variants were wrong; the character branch now checks flags first.

Finding it this way was the fourth validation-ordering defect review has caught
that the curated tables could not, so this adds the net that finds them
automatically instead. StringFormatConformanceTest copies the formatter and its
exceptions into a neutral package -- nothing can load a java.lang class
otherwise -- compiles them, and drives about a million single-specifier format
strings through both it and the JDK, comparing the exact rendering or the exact
exception. Single-specifier is deliberate: the JVM validates a whole format
string before formatting any of it, so a format with several broken specifiers
can legitimately report a different one first, and restricting to one specifier
removes that variable.

It immediately found a fifth defect nobody had reported: the JVM rejects a wrong
argument type for %x and %o ahead of the sign-flag check it defers to print time,
so "%+x" with a String raised FormatFlagsConversionMismatchException here where
the JVM raises IllegalFormatConversionException. 1470 cases. Fixed by accepting
the argument's type before applying the deferred flags.

The sweep is now zero mismatches on JDK 8, 11, 17, 21 and 25. Java 8 ignores a
width on the literal "%" conversion where Java 9 honours it, so the test detects
that at runtime rather than pinning a version, and asserts a modern JDK skips
nothing.

Confirmed the test fails when the code is wrong by restoring the character bug:
it reports "%-0c" by name.

Regression cases for both orderings added to the device and differential tables.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Human review recommended

It changes core runtime behavior (formatting + floating-point string conversion) across multiple ParparVM backends and should receive final human review despite strong test coverage.

Review details

Suppressed comments (2)

scripts/hellocodenameone/tools/GenerateStringFormatCases.java:325

  • The generator still prints the old (pre-rename) file path in its header comment, which is inconsistent with the current filename and with StringFormatTest’s javadoc reference. This makes it harder to follow the “regenerate and paste” workflow.
        System.out.println("// Generated by scripts/hellocodenameone/tools/generate-string-format-cases.java");

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/StringFormatTest.java:69

  • This embedded generated header comment still references the old generator path (generate-string-format-cases.java). Since the generator file is now GenerateStringFormatCases.java, update this to match so readers can easily find the tool that produced this table.
// Generated by scripts/hellocodenameone/tools/generate-string-format-cases.java
// on Azul Systems, Inc. JDK 25 -- do not edit by hand.
  • Files reviewed: 38/38 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

The stored reports carried it as not-run, which was wrong on its own terms: the
point of adding a test is that it runs, and marking a brand new test as not-run
invents a state it was never in. It also mis-reported the java-standard-apis
feature on the website as incomplete.

This PR's CI ran it on all eleven ports and it passed on every one, so that is
what the reports say now. Verified per port from the port-status artifacts:
android, ios-gl, ios-metal, javascript, linux-arm64, linux-x64, mac-native,
tvos, watchos, windows-arm64, windows-x64.

The only delta against master in each report is now +1 pass and the new entry;
every other counter, including not-run, is back to its original value.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 16:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b2958f7a4b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/website/data/port_status_reports/android.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Human review recommended

It makes broad, correctness-sensitive changes to core runtime formatting and floating-point string conversion across multiple backends, which warrants final human review.

Review details
  • Files reviewed: 38/38 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Review is right and this was my error. Each stored report is a snapshot of one
specific run, pinned by its commit and run_url fields, not a running description
of the port. Every one of them records a July 15 or 16 commit:

    android        b51436a   2026-07-16
    ios-gl         205dcc6   2026-07-16
    tvos           205dcc6   2026-07-16
    watchos        dec3d17   2026-07-15
    windows-x64    d17e18e   2026-07-16
    ...

None of those commits contains or registers StringFormatTest, so none of those
runs could have executed it. Writing "pass" into them attributed a result to a
run that provably never produced one, which is fabricating test results no matter
that the test does pass elsewhere.

Back to not-run, which is what those runs actually did with a test that did not
exist yet. The real results land when master publishes reports from a run whose
commit contains the test; port-status-publish.yml does that on master push, and
the entry is already wired up to receive them.

The evidence that the test passes on all eleven ports belongs in the PR
discussion, not hand-written into a machine-generated snapshot.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 4, 2026 00:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

A few verified issues remain (test determinism around locale, stale generator path references, and an API-visible arbitrary numeric cap in the format parser) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (4)

scripts/hellocodenameone/tools/GenerateStringFormatCases.java:325

  • The generator prints a stale source path in its output header ("generate-string-format-cases.java"), but the file in this PR is named "GenerateStringFormatCases.java". This makes the generated block misleading and also propagates into StringFormatTest’s embedded header comment.
        System.out.println("// Generated by scripts/hellocodenameone/tools/generate-string-format-cases.java");

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/StringFormatTest.java:69

  • This embedded header comment references the old generator path ("generate-string-format-cases.java"), but the generator in this PR is "GenerateStringFormatCases.java". Keeping these in sync helps future updates/regeneration.
// Generated by scripts/hellocodenameone/tools/generate-string-format-cases.java
// on Azul Systems, Inc. JDK 25 -- do not edit by hand.

vm/tests/src/test/resources/com/codename1/tools/translator/StringFormatApp.java:281

  • StringFormatIntegrationTest diffs ParparVM output against a JVM run, but StringFormatApp doesn’t force a stable default Locale. On machines with a non-English default locale, Java’s String.format may use different decimal/grouping separators or locale-sensitive uppercasing, causing spurious diffs unrelated to ParparVM behavior.
    vm/JavaAPI/src/java/lang/StringFormatter.java:783
  • parseNumber() rejects any width/precision/index above 1,000,000 with a generic IllegalArgumentException. This introduces a non-JDK limit and exception behavior for valid format strings (large widths are legal in java.util.Formatter, even if they may OOM at runtime). If you want to guard the parse, it’s safer to only reject integer overflow (matching Integer.parseInt-style behavior) rather than an arbitrary cap.
        int result = 0;
        for (int i = start; i < end; i++) {
            result = result * 10 + (value.charAt(i) - '0');
            if (result > 1000000) {
                // Guard against a width so large it would only be a denial of service.
                throw new IllegalArgumentException(value.substring(start, end));
            }
  • Files reviewed: 38/38 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

…enerator path

Four points from the latest Copilot review, all of which hold.

parseNumber rejected any width, precision or argument index above 1,000,000 with
a bare IllegalArgumentException. That was my invention, and it rejected legal
format strings: "%1000001d" really does produce a million characters on the JVM.
It now mirrors what the JVM does instead, which the JVM was asked directly:

    "%1000001d"       -> a 1000001 character string
    "%12.1000001f"    -> a 1000003 character string
    "%2147483648d"    -> IllegalFormatWidthException
    "%.99999999999f"  -> IllegalFormatPrecisionException
    "%2147483648$d"   -> IllegalFormatArgumentIndexException
    "%1000001$d"      -> MissingFormatArgumentException

A digit run that does not fit in an int saturates, and each field turns that into
the exception it calls for. All ten probes match. The conformance sweep now
covers oversized fields explicitly, since its widths only went up to 12 and it
could never have found this.

StringFormatIntegrationTest diffed ParparVM against a JVM run without pinning a
locale. This formatter is locale independent while the JVM side follows the
default, so a build machine in a comma-decimal locale would have produced diffs
that had nothing to do with ParparVM. The JVM side now runs with an explicit
en_US.

The generator printed its own former file name into the header of everything it
generated, which had propagated into StringFormatTest. Fixed and regenerated.

Full ParparVM suite 412 green, device test clean, contract and headers green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 4, 2026 00:54
@shai-almog

Copy link
Copy Markdown
Collaborator Author

Addressed the four suppressed comments from the latest Copilot review in a1208ab. All four were valid.

1. parseNumber had an invented cap. It rejected any width, precision or argument index above 1,000,000 with a bare IllegalArgumentException. That was mine, not the JDK's, and it rejected legal format strings. Asked the JVM what it actually does rather than guessing:

"%1000001d"       -> a 1000001 character string      <- legal, we were throwing
"%12.1000001f"    -> a 1000003 character string      <- legal, we were throwing
"%2147483648d"    -> IllegalFormatWidthException
"%.99999999999f"  -> IllegalFormatPrecisionException
"%2147483648$d"   -> IllegalFormatArgumentIndexException
"%1000001$d"      -> MissingFormatArgumentException

A digit run that does not fit in an int now saturates and each field turns that into the exception it calls for. All ten probes match the JVM.

Worth noting why the million-case sweep missed this: its widths only go up to 12, so it could never reach the cap. The sweep now covers oversized fields explicitly.

2. StringFormatIntegrationTest did not pin a locale. Real latent flake -- that test diffs ParparVM against a JVM run, and this formatter is locale independent while the JVM side follows the default locale. A build machine in a comma-decimal locale would have produced diffs that had nothing to do with ParparVM. The JVM side now launches with an explicit en_US. (The device-side StringFormatTest already handled this differently, by probing the platform separators, because it cannot control the locale of an iOS or Android device.)

3 and 4. Stale generator path. The generator printed its own former file name into the header of everything it generated, which had propagated into StringFormatTest. Fixed and regenerated.

Verification after the change: full ParparVM suite 412 green, the ~1M-case conformance sweep still zero on JDK 8/11/17/21/25, device test clean on the JVM, port-status contract and copyright headers green.

On the one CI failure showing on the previous commit -- build-test (8), HealthEdtDeliveryTest.aFacadeActionDeliversOnTheEdt -- that is not from this branch. That commit changed only 11 JSON files under docs/website/data/port_status_reports/, the same job passed on the commit before it, and master fails the same test with the identical assertion at c3dabfdf, which contains none of this work.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

The new formatter currently rejects the standard %F conversion and the conformance sweep omits %F, leaving a spec-compatibility gap untested.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (2)

vm/JavaAPI/src/java/lang/StringFormatter.java:250

  • StringFormatter currently rejects the standard Java Formatter conversion '%F' (uppercase floating-point). In java.util.Formatter, both %f and %F are valid; %F mainly affects the casing of NaN/Infinity. Because validateSpecifier only whitelists uppercase conversions in "SBHCXEG", any %F format string will incorrectly throw UnknownFormatConversionException.
    private static char validateSpecifier(char conversion, boolean upper, int flags,
                                          int width, int precision) {
        if (upper && "SBHCXEG".indexOf(conversion) < 0) {
            // 'D' and 'O' have no uppercase form in java.util.Formatter.
            throw new UnknownFormatConversionException(String.valueOf(conversion));
        }

vm/tests/src/test/java/com/codename1/tools/translator/StringFormatConformanceTest.java:79

  • The exhaustive conformance sweep doesn't include the standard '%F' conversion, so it won't catch regressions/bugs in uppercase floating-point formatting (or the current rejection of %F). Since this test is meant to cover all supported conversions against the JDK, add "F" to the CONVERSIONS list.
  • Files reviewed: 38/38 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1208ab9a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// rather than silently wrong. See the class javadoc.
throw new UnknownFormatConversionException(String.valueOf(conversion));
}
checkFlags(conversion, lower, flags, width, precision);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize uppercase conversions in exception metadata

When a supported uppercase conversion is rejected, this passes the original uppercase character into the exception path: for example, %G with an Integer produces an IllegalFormatConversionException whose getConversion() is G, and %+S produces a FormatFlagsConversionMismatchException containing S. The JDK normalizes these values to g and s, respectively, so callers inspecting the newly added getters or messages observe incompatible results; retain the uppercase flag for rendering but use lower when constructing conversion-related exceptions.

Useful? React with 👍 / 👎.

…eep first

The oversized-field assertions I added in the previous commit failed vm-tests,
and that failure was mine. A width too large for an int is silently dropped up
to at least Java 11 and rejected from Java 17 on:

    "%2147483648d"  ->  "1"                            on JDK 8 and 11
    "%2147483648d"  ->  IllegalFormatWidthException    on JDK 17, 21 and 25

The sweep compares against whichever JDK runs it, CI runs it on 8, and this
formatter follows the modern behaviour, so the comparison could not hold there.
Those specs are now gated on a runtime probe, the way the "%5%" width difference
already was. The large-but-representable cases -- "%1000001d" and friends, which
are the ones the review comment was actually about -- are still asserted
unconditionally, because every JDK agrees on them.

The probe needed a guard of its own: on a modern JDK it throws rather than
returning a value, which the cross-JDK check caught.

Also moved the oversized block after the main sweep assertion. It ran before it,
so a failure there masked the result of the million-case sweep entirely -- the CI
run that failed never reported whether the sweep itself was clean.

Verified per JDK rather than assumed: sweep and oversized checks are both clean
on 8, 11, 17, 21 and 25, and the test passes under Maven on JDK 8, which is the
configuration that failed. Full ParparVM suite 412 green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 4, 2026 07:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Human review recommended

It replaces core formatting behavior across multiple runtimes and adjusts native numeric rendering, which is high-impact and warrants final human validation despite the strong test additions.

Review details
  • Files reviewed: 38/38 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15faf83a9f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +229 to +230
if (args != null && nextArg >= args.length) {
throw new MissingFormatArgumentException(format.substring(specStart, pos));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevalidate every specifier before selecting arguments

The earlier single-specifier validation fix does not cover malformed specifiers later in the format: with no arguments, String.format("%s %q") on the JDK throws UnknownFormatConversionException because the whole format is parsed before argument selection, while this bounds check immediately throws MissingFormatArgumentException for the first %s. The same masking occurs for later duplicate flags, missing widths, and invalid precisions, so parse and validate all specifiers before beginning argument lookup and conversion.

Useful? React with 👍 / 👎.

Comment on lines +389 to +392
private static void failMissingWidth(char conversion, int flags, int width, int needsWidth) {
if (width < 0 && (flags & needsWidth) != 0) {
throw new MissingFormatWidthException("%" + flagString(flags) + conversion);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit indexes in missing-width metadata

When a width-dependent flag is combined with an explicit argument index, this reconstruction discards the index from the new exception's observable format specifier. For example, %1$-s produces MissingFormatWidthException.getFormatSpecifier() equal to %-s, whereas the JDK reports %-1$s; %2$0d similarly becomes %0d instead of %02$d. Pass the parsed argument index into this path and construct the canonical indexed specifier so callers inspecting the getter or message receive compatible metadata.

Useful? React with 👍 / 👎.

…ng the test

My hand edits to these files are gone. They are machine generated snapshots of a
single run, pinned by commit and run_url, and I had no business writing statuses
into them by hand -- first not-run, which inflated every port's count from 5 to 6,
then pass, which attributed a result to July runs that could not have produced it.

These are the reports this PR's own CI generated, at commit 12ecf37, which
contains and registers StringFormatTest. Nothing here is written by hand.

java-standard-apis now executes everywhere: FloatingToString, Java17, NanoTimeApi,
StreamApi, StringApi, StringFormat and TimeApi all report a real result on all
eleven ports rather than not-run. not-run drops from 5 to 0 on the device ports,
and to 3 on linux and windows where three tests genuinely do not run.

The reports also carry seven failures on linux and windows -- AudioMixerApi,
Crypto, FileSystemStorageOpenInputStreamMissing, SurfacesPublish, TimeApi and
friends. Those are not from this branch. Master's own run today at 9783b6c
records the identical seven on the same ports, and the stored snapshots simply
predate them by three weeks. They arrive here because the reports are being
refreshed, not because anything in this PR caused them.

Contract validate and the contract unit tests are green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 4, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Human review recommended

It changes core formatting and floating-point/string rendering behavior across multiple runtimes (JavaAPI, ParparVM native, and JS), which is high-impact and warrants final human review despite the added conformance tests.

Review details
  • Files reviewed: 38/38 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d675aa4f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if ((flags & FLAG_HASH) != 0) {
throw new FormatFlagsConversionMismatchException("#", conversion);
}
return text(arg == null ? "null" : arg.toString(), upper, flags, width, precision);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Render a null toString result for bare %s

When an argument's toString() implementation returns null, the unadorned %s conversion passes that null into text(), which immediately dereferences it and throws NullPointerException. The JDK instead renders String.format("%s", object) as "null" in this scenario, so existing objects with an unusual but permitted toString() result regress from printable output to a runtime failure; normalize the result to the literal "null" before calling text().

Useful? React with 👍 / 👎.

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.

[Bug] IOS crash with "runtime exception"

2 participants