Skip to content

Migrate example project and build tooling to Java 17; add compatibility stubs and version parsing#4592

Closed
shai-almog wants to merge 2 commits intomasterfrom
codex/update-hellocodenameone-for-java-17-tk1sta
Closed

Migrate example project and build tooling to Java 17; add compatibility stubs and version parsing#4592
shai-almog wants to merge 2 commits intomasterfrom
codex/update-hellocodenameone-for-java-17-tk1sta

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • Modernize the example multi-module hellocodenameone project and CI/workspace scripts to use Java 17 as the compile and test target.
  • Avoid fragile parsing of Java version strings and hard failures when verifying library java versions.
  • Provide minimal compatibility stubs for Java string-concat API classes used internally to prevent missing-symbol issues when compiling against newer runtime APIs.

Description

  • Updated hellocodenameone pom and module pom files to set <maven.compiler.source> and <maven.compiler.target> to 17, and bumped project java.version and test java versions to 17.
  • Added Java 17 detection and preference to wrapper and helper scripts (mvnw, mvnw.cmd, run.*, build.*, build.bat, mvnw helpers) and ensured JAVA_HOME is set to a JDK 17 when available, and updated build-ios-app.sh to run Maven using JAVA17_HOME while logging versions.
  • Added a small test Java17LanguageFeaturesTest in the example common test sources to validate Java 17 language features compile in the test classpath.
  • Introduced a robust parseJavaVersion helper in CN1BuildMojo and InstallCn1libsMojo to safely parse human-readable Java version strings and avoid NumberFormatException when comparing library/project java versions.
  • Added stub implementation files for java.lang.invoke.StringConcatFactory in two locations to provide compatibility placeholders used by string concatenation handling.
  • Minor GitHub Actions workflow whitespace cleanup and ensured CocoaPods tooling step remains in the macOS job.

Testing

  • Ran the example packaging flow for the iOS example via the build script which invokes ./mvnw package -DskipTests and the script completed successfully.
  • Executed mvn test for the hellocodenameone/common test module to verify Java17LanguageFeaturesTest compiles and runs, and the test passed.
  • Verified shell and batch script paths and java -version checks by running mvnw/wrapper bootstrap locally and confirming JAVA_HOME selection logic prefers a JDK 17 installation.

Codex Task

…tk1sta

Signed-off-by: Shai Almog <67850168+shai-almog@users.noreply.github.com>
@github-actions
Copy link

github-actions bot commented Mar 5, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Mar 5, 2026

Android screenshot updates

Compared 32 screenshots: 31 matched, 1 error.

  • graphics-draw-line — comparison error. Comparison error: PNG chunk truncated before CRC while processing: /home/runner/work/_temp/cn1ss-Sv9XIz/graphics-draw-line.png

    No preview available for this screenshot.
    Full-resolution PNG saved as graphics-draw-line.png in workflow artifacts.

Native Android coverage

  • 📊 Line coverage: 7.30% (3711/50862 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.65% (18059/319659), branch 2.75% (856/31113), complexity 3.40% (1011/29741), method 5.98% (828/13853), class 9.63% (176/1827)
    • 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/712 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)

@github-actions
Copy link

github-actions bot commented Mar 5, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 146 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 10258 ms

  • Hotspots (Top 20 sampled methods):

    • 20.90% java.util.ArrayList.indexOf (375 samples)
    • 18.67% java.lang.String.indexOf (335 samples)
    • 17.34% com.codename1.tools.translator.Parser.isMethodUsed (311 samples)
    • 7.41% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (133 samples)
    • 4.79% java.lang.Object.hashCode (86 samples)
    • 3.73% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (67 samples)
    • 2.34% java.lang.System.identityHashCode (42 samples)
    • 1.56% java.lang.StringBuilder.append (28 samples)
    • 1.56% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (28 samples)
    • 1.51% com.codename1.tools.translator.BytecodeMethod.optimize (27 samples)
    • 1.23% com.codename1.tools.translator.Parser.cullMethods (22 samples)
    • 1.17% com.codename1.tools.translator.BytecodeMethod.appendMethodC (21 samples)
    • 1.00% java.lang.StringCoding.encode (18 samples)
    • 0.95% com.codename1.tools.translator.ByteCodeClass.markDependent (17 samples)
    • 0.95% java.io.UnixFileSystem.getBooleanAttributes0 (17 samples)
    • 0.89% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (16 samples)
    • 0.89% sun.nio.fs.UnixNativeDispatcher.open0 (16 samples)
    • 0.67% sun.nio.ch.FileDispatcherImpl.write0 (12 samples)
    • 0.56% java.io.FileOutputStream.writeBytes (10 samples)
    • 0.56% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (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 shai-almog closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant