Skip to content

Generate JavaSE desktop stub from codenameone_settings.properties#5043

Merged
shai-almog merged 1 commit into
masterfrom
fix-desktop-stub-generation
May 26, 2026
Merged

Generate JavaSE desktop stub from codenameone_settings.properties#5043
shai-almog merged 1 commit into
masterfrom
fix-desktop-stub-generation

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Initializr-generated projects ship only the Lifecycle subclass and no <MainName>Stub.java, so mvn verify -P run-desktop failed with ClassNotFoundException. The stub carries app-specific configuration (title, dimensions, fullscreen flag, etc.) and should be emitted by the plugin from settings/build-hints, the way IPhoneBuilder and AndroidGradleBuilder already do for their targets.
  • GenerateDesktopAppWrapperMojo now writes target/generated-sources/cn1-desktop/<pkg>/<MainName>Stub.java from a packaged template, substituting codename1.mainName / packageName / displayName / version and the codename1.arg.desktop.* build hints (title, width, height, fullscreen, resizable, adaptToRetina), and adds the directory as a compile source root.
  • A hand-rolled javase/src/desktop/java/<pkg>/<MainName>Stub.java still wins so apps can fully customize when the hint surface is not enough.

Test plan

  • Plugin compiles and installs to local repo (mvn install in maven/codenameone-maven-plugin).
  • Initializr-style project (MyAppName extends Lifecycle, no Stub on disk) succeeds with mvn verify -P run-desktop: stub is generated, compiled, and exec:java boots JavaSEPort instead of failing with ClassNotFoundException.
  • Override path: dropping a hand-written MyAppNameStub.java under javase/src/desktop/java/com/example/myapp/ causes the mojo to log Custom desktop stub found ... - skipping generation and use the user file.
  • Optional follow-ups (not in this PR): wire desktop.framePrepare / desktop.frameShow body-injection hints; wire desktop.fontFaces to a comma-separated build hint.

🤖 Generated with Claude Code

Initializr-generated projects ship only the Lifecycle subclass and no
<MainName>Stub.java, so `mvn verify -P run-desktop` failed with
ClassNotFoundException. The stub carries app-specific configuration
(title, dimensions, fullscreen flag, etc.) and should be emitted by the
plugin from settings/build-hints rather than shipped statically, the way
the iOS and Android builders already do.

GenerateDesktopAppWrapperMojo now writes
target/generated-sources/cn1-desktop/<pkg>/<MainName>Stub.java from a
packaged template, substituting codename1.mainName / packageName /
displayName / version and the codename1.arg.desktop.* build hints
(title, width, height, fullscreen, resizable, adaptToRetina), and adds
the directory as a compile source root. A hand-rolled
src/desktop/java/<pkg>/<MainName>Stub.java still wins so apps can take
full control when the hint surface is not enough.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 26, 2026

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

@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 26, 2026

Compared 110 screenshots: 110 matched.

Native Android coverage

  • 📊 Line coverage: 11.86% (6815/57481 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.64% (34229/354909), branch 4.18% (1411/33740), complexity 5.19% (1681/32374), method 8.99% (1361/15146), class 14.44% (303/2099)
    • 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: 11.86% (6815/57481 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 9.64% (34229/354909), branch 4.18% (1411/33740), complexity 5.19% (1681/32374), method 8.99% (1361/15146), class 14.44% (303/2099)
    • 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 981.000 ms
Base64 CN1 encode 208.000 ms
Base64 encode ratio (CN1/native) 0.212x (78.8% faster)
Base64 native decode 1015.000 ms
Base64 CN1 decode 187.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 26, 2026

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 62000 ms
Simulator Boot (Run) 2000 ms
App Install 16000 ms
App Launch 8000 ms
Test Execution 338000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 559.000 ms
Base64 CN1 encode 1309.000 ms
Base64 encode ratio (CN1/native) 2.342x (134.2% slower)
Base64 native decode 275.000 ms
Base64 CN1 decode 1012.000 ms
Base64 decode ratio (CN1/native) 3.680x (268.0% slower)
Base64 SIMD encode 510.000 ms
Base64 encode ratio (SIMD/native) 0.912x (8.8% faster)
Base64 encode ratio (SIMD/CN1) 0.390x (61.0% faster)
Base64 SIMD decode 401.000 ms
Base64 decode ratio (SIMD/native) 1.458x (45.8% slower)
Base64 decode ratio (SIMD/CN1) 0.396x (60.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 57.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.175x (82.5% faster)
Image applyMask (SIMD off) 120.000 ms
Image applyMask (SIMD on) 54.000 ms
Image applyMask ratio (SIMD on/off) 0.450x (55.0% faster)
Image modifyAlpha (SIMD off) 117.000 ms
Image modifyAlpha (SIMD on) 53.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.453x (54.7% faster)
Image modifyAlpha removeColor (SIMD off) 136.000 ms
Image modifyAlpha removeColor (SIMD on) 65.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.478x (52.2% faster)
Image PNG encode (SIMD off) 1157.000 ms
Image PNG encode (SIMD on) 859.000 ms
Image PNG encode ratio (SIMD on/off) 0.742x (25.8% faster)
Image JPEG encode 435.000 ms

@shai-almog shai-almog merged commit 9892ccd into master May 26, 2026
25 of 26 checks passed
@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 26, 2026

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

Benchmark Results

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

Build and Run Timing

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

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 422.000 ms
Base64 CN1 encode 1363.000 ms
Base64 encode ratio (CN1/native) 3.230x (223.0% slower)
Base64 native decode 385.000 ms
Base64 CN1 decode 851.000 ms
Base64 decode ratio (CN1/native) 2.210x (121.0% slower)
Base64 SIMD encode 441.000 ms
Base64 encode ratio (SIMD/native) 1.045x (4.5% slower)
Base64 encode ratio (SIMD/CN1) 0.324x (67.6% faster)
Base64 SIMD decode 380.000 ms
Base64 decode ratio (SIMD/native) 0.987x (1.3% faster)
Base64 decode ratio (SIMD/CN1) 0.447x (55.3% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 56.000 ms
Image createMask (SIMD on) 12.000 ms
Image createMask ratio (SIMD on/off) 0.214x (78.6% faster)
Image applyMask (SIMD off) 158.000 ms
Image applyMask (SIMD on) 57.000 ms
Image applyMask ratio (SIMD on/off) 0.361x (63.9% faster)
Image modifyAlpha (SIMD off) 131.000 ms
Image modifyAlpha (SIMD on) 72.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.550x (45.0% faster)
Image modifyAlpha removeColor (SIMD off) 184.000 ms
Image modifyAlpha removeColor (SIMD on) 173.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.940x (6.0% faster)
Image PNG encode (SIMD off) 1160.000 ms
Image PNG encode (SIMD on) 885.000 ms
Image PNG encode ratio (SIMD on/off) 0.763x (23.7% faster)
Image JPEG encode 486.000 ms

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