Skip to content

Fix WMI_WRONG_MAP_ITERATOR in JSONParser and make SpotBugs fail CI#5048

Merged
shai-almog merged 1 commit into
masterfrom
fix-spotbugs-wmi-jsonparser
May 27, 2026
Merged

Fix WMI_WRONG_MAP_ITERATOR in JSONParser and make SpotBugs fail CI#5048
shai-almog merged 1 commit into
masterfrom
fix-spotbugs-wmi-jsonparser

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Replaced keySet() + m.get(key) iteration in JSONParser.writeJsonValue with entrySet() iteration, clearing the SpotBugs WMI_WRONG_MAP_ITERATOR warning at CodenameOne/src/com/codename1/io/JSONParser.java:853. Null-drop semantics and the surrounding comment are preserved.
  • Added the check goal to the SpotBugs execution in maven/core-unittests/pom.xml. The previous binding only ran the spotbugs goal, which generates the XML report but does not abort the build on findings regardless of failOnError. check honors the existing Low threshold and failOnError=true, so any new violation (such as another WMI_WRONG_MAP_ITERATOR) will fail CI instead of being silently uploaded as a quality artifact. The spotbugs goal stays bound so the quality-artifact pipeline still receives the XML report on success.

Test plan

  • mvn -DunitTests=true -pl core-unittests -am -DskipTests -Plocal-dev-javase verify (JDK 8) — SpotBugs check reports BugInstance size is 0 and build succeeds.
  • PR CI builds (matrix on JDK 8/17/21) — confirm check runs and does not regress other modules.

🤖 Generated with Claude Code

@shai-almog shai-almog force-pushed the fix-spotbugs-wmi-jsonparser branch from ed4b3ca to 770e1c0 Compare May 27, 2026 10:50
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

✅ 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 27, 2026

Compared 116 screenshots: 116 matched.

Native Android coverage

  • 📊 Line coverage: 12.40% (7181/57934 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.11% (36121/357185), branch 4.28% (1447/33832), complexity 5.29% (1719/32478), method 9.21% (1400/15204), class 15.04% (318/2114)
    • 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.40% (7181/57934 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 10.11% (36121/357185), branch 4.28% (1447/33832), complexity 5.29% (1719/32478), method 9.21% (1400/15204), class 15.04% (318/2114)
    • 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 1269.000 ms
Base64 CN1 encode 222.000 ms
Base64 encode ratio (CN1/native) 0.175x (82.5% faster)
Base64 native decode 1103.000 ms
Base64 CN1 decode 203.000 ms
Base64 decode ratio (CN1/native) 0.184x (81.6% faster)
Image encode benchmark status skipped (SIMD unsupported)

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 27, 2026

Compared 11 screenshots: 11 matched.
✅ JavaSE simulator integration screenshots matched stored baselines.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 27, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 107000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 3000 ms
Test Execution 320000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 525.000 ms
Base64 CN1 encode 1448.000 ms
Base64 encode ratio (CN1/native) 2.758x (175.8% slower)
Base64 native decode 338.000 ms
Base64 CN1 decode 979.000 ms
Base64 decode ratio (CN1/native) 2.896x (189.6% slower)
Base64 SIMD encode 380.000 ms
Base64 encode ratio (SIMD/native) 0.724x (27.6% faster)
Base64 encode ratio (SIMD/CN1) 0.262x (73.8% faster)
Base64 SIMD decode 413.000 ms
Base64 decode ratio (SIMD/native) 1.222x (22.2% slower)
Base64 decode ratio (SIMD/CN1) 0.422x (57.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 55.000 ms
Image createMask (SIMD on) 9.000 ms
Image createMask ratio (SIMD on/off) 0.164x (83.6% faster)
Image applyMask (SIMD off) 120.000 ms
Image applyMask (SIMD on) 56.000 ms
Image applyMask ratio (SIMD on/off) 0.467x (53.3% faster)
Image modifyAlpha (SIMD off) 119.000 ms
Image modifyAlpha (SIMD on) 57.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.479x (52.1% faster)
Image modifyAlpha removeColor (SIMD off) 152.000 ms
Image modifyAlpha removeColor (SIMD on) 68.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.447x (55.3% faster)
Image PNG encode (SIMD off) 1250.000 ms
Image PNG encode (SIMD on) 813.000 ms
Image PNG encode ratio (SIMD on/off) 0.650x (35.0% faster)
Image JPEG encode 637.000 ms

@github-actions
Copy link
Copy Markdown
Contributor

Cloudflare Preview

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 27, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 648 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 10853 ms

  • Hotspots (Top 20 sampled methods):

    • 21.63% java.lang.String.indexOf (415 samples)
    • 20.58% java.util.ArrayList.indexOf (395 samples)
    • 18.08% com.codename1.tools.translator.Parser.isMethodUsed (347 samples)
    • 5.21% java.lang.Object.hashCode (100 samples)
    • 5.11% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (98 samples)
    • 2.61% java.lang.System.identityHashCode (50 samples)
    • 1.93% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (37 samples)
    • 1.82% com.codename1.tools.translator.ByteCodeClass.updateAllDependencies (35 samples)
    • 1.82% com.codename1.tools.translator.ByteCodeClass.markDependent (35 samples)
    • 1.77% com.codename1.tools.translator.BytecodeMethod.appendMethodSignatureSuffixFromDesc (34 samples)
    • 1.41% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (27 samples)
    • 0.94% java.lang.StringBuilder.append (18 samples)
    • 0.83% com.codename1.tools.translator.BytecodeMethod.equals (16 samples)
    • 0.78% com.codename1.tools.translator.BytecodeMethod.optimize (15 samples)
    • 0.78% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (15 samples)
    • 0.78% sun.nio.fs.UnixNativeDispatcher.open0 (15 samples)
    • 0.63% com.codename1.tools.translator.Parser.cullMethods (12 samples)
    • 0.57% java.io.FileOutputStream.open0 (11 samples)
    • 0.52% com.codename1.tools.translator.ByteCodeClass.generateCCode (10 samples)
    • 0.52% java.lang.StringCoding.encode (10 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
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 27, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 66000 ms
Simulator Boot (Run) 1000 ms
App Install 14000 ms
App Launch 12000 ms
Test Execution 287000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 535.000 ms
Base64 CN1 encode 1357.000 ms
Base64 encode ratio (CN1/native) 2.536x (153.6% slower)
Base64 native decode 309.000 ms
Base64 CN1 decode 1032.000 ms
Base64 decode ratio (CN1/native) 3.340x (234.0% slower)
Base64 SIMD encode 610.000 ms
Base64 encode ratio (SIMD/native) 1.140x (14.0% slower)
Base64 encode ratio (SIMD/CN1) 0.450x (55.0% faster)
Base64 SIMD decode 553.000 ms
Base64 decode ratio (SIMD/native) 1.790x (79.0% slower)
Base64 decode ratio (SIMD/CN1) 0.536x (46.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 64.000 ms
Image createMask (SIMD on) 11.000 ms
Image createMask ratio (SIMD on/off) 0.172x (82.8% faster)
Image applyMask (SIMD off) 194.000 ms
Image applyMask (SIMD on) 616.000 ms
Image applyMask ratio (SIMD on/off) 3.175x (217.5% slower)
Image modifyAlpha (SIMD off) 215.000 ms
Image modifyAlpha (SIMD on) 84.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.391x (60.9% faster)
Image modifyAlpha removeColor (SIMD off) 604.000 ms
Image modifyAlpha removeColor (SIMD on) 104.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.172x (82.8% faster)
Image PNG encode (SIMD off) 1233.000 ms
Image PNG encode (SIMD on) 897.000 ms
Image PNG encode ratio (SIMD on/off) 0.727x (27.3% faster)
Image JPEG encode 503.000 ms

JSONParser.writeJsonValue iterated the Map via keySet() and re-resolved
each value with m.get(key), tripping SpotBugs' WMI_WRONG_MAP_ITERATOR
(performance). Switched to entrySet() iteration so the hash lookup is
done once per entry; the null-drop semantics and surrounding comment
are preserved.

The SpotBugs execution in maven/core-unittests was only bound to the
`spotbugs` goal, which generates the XML report but does not break the
build on findings regardless of `failOnError`. Added the `check` goal
to the same execution so any reported bug (>= Low priority, per the
existing threshold) aborts CI. The `spotbugs` goal stays bound so the
quality-artifact pipeline still receives the XML report on success.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shai-almog shai-almog force-pushed the fix-spotbugs-wmi-jsonparser branch from 79e070d to 9b39e7e Compare May 27, 2026 14:05
@shai-almog shai-almog merged commit 34be741 into master May 27, 2026
21 checks passed
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