Skip to content

Move example project and build scripts to Java 17; add compatibility helpers and Java version parsing#4595

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

Move example project and build scripts to Java 17; add compatibility helpers and Java version parsing#4595
shai-almog wants to merge 2 commits intomasterfrom
codex/update-hellocodenameone-for-java-17-bjxela

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • Move the example multi-module project and build scripts to use Java 17 so modern language features can be compiled and tested.
  • Improve robustness of java version handling in Maven plugin code to correctly compare project and library Java versions.
  • Add minimal runtime compatibility stubs and ProGuard suppressions to avoid false positives during compliance checks with newer JDK toolchains.

Description

  • Bumped example project and module POMs and compiler settings from Java 1.8 to Java 17 and updated test/compile-related properties in the root example pom.xml.
  • Added Java 17 detection and prefer-JDK-17 logic to wrapper and helper scripts (mvnw, mvnw.cmd, build.sh, run.sh, build.bat, run.bat, mvnw wrappers) and set JAVA_HOME for maven invocations in scripts/build-ios-app.sh.
  • Added a Java17LanguageFeaturesTest to the example common tests to validate new language features compile in tests.
  • Introduced a safe parseJavaVersion(String,int) helper and replaced fragile integer parsing in CN1BuildMojo and InstallCn1libsMojo to properly normalize and compare Java versions.
  • Added DEFAULT_DONTWARN_CLASSES and emit -dontwarn entries in ComplianceCheckMojo to suppress known non-actionable warnings (e.g. java.rmi.Remote, java.util.Arrays$ArrayList).
  • Added placeholder StringConcatFactory.java stubs in Ports/CLDC11 and vm/JavaAPI to provide minimal compatibility for invokedynamic-based string concat during builds.

Testing

  • Ran the example module tests including the new Java17LanguageFeaturesTest via Maven and the test passed.
  • Packaged the example modules with mvn package (wrapper) to verify compiler/toolchain changes and the build completed successfully.
  • Verified shell and batch wrapper logic for preferring JDK 17 by running the wrapper scripts in CI-like environments (detection and JAVA_HOME override behavior exercised and OK).

Codex Task

…bjxela

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 updated.

  • landscape — updated screenshot. Screenshot differs (640x320 px, bit depth 8).

    landscape
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as landscape.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% (18061/319659), branch 2.75% (856/31113), complexity 3.40% (1010/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: 9912 ms

  • Hotspots (Top 20 sampled methods):

    • 20.66% java.lang.String.indexOf (353 samples)
    • 18.20% com.codename1.tools.translator.Parser.isMethodUsed (311 samples)
    • 14.69% com.codename1.tools.translator.Parser.addToConstantPool (251 samples)
    • 9.30% java.util.ArrayList.indexOf (159 samples)
    • 4.39% java.lang.Object.hashCode (75 samples)
    • 3.92% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (67 samples)
    • 2.57% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (44 samples)
    • 2.34% java.lang.System.identityHashCode (40 samples)
    • 1.58% com.codename1.tools.translator.Parser.cullMethods (27 samples)
    • 1.23% com.codename1.tools.translator.BytecodeMethod.optimize (21 samples)
    • 1.23% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (21 samples)
    • 1.05% java.lang.StringBuilder.append (18 samples)
    • 0.94% sun.nio.fs.UnixNativeDispatcher.open0 (16 samples)
    • 0.88% com.codename1.tools.translator.BytecodeMethod.equals (15 samples)
    • 0.76% java.lang.StringCoding.encode (13 samples)
    • 0.70% com.codename1.tools.translator.ByteCodeClass.isDefaultInterfaceMethod (12 samples)
    • 0.70% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (12 samples)
    • 0.64% java.lang.Integer.getChars (11 samples)
    • 0.64% java.io.FileOutputStream.open0 (11 samples)
    • 0.64% com.codename1.tools.translator.ByteCodeClass.markDependent (11 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 6, 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