Skip to content

Add @Concrete annotation and optimize ParparVM invoke resolution#4746

Merged
liannacasper merged 10 commits intomasterfrom
codex/add-concrete-annotation-to-codename-one
Apr 14, 2026
Merged

Add @Concrete annotation and optimize ParparVM invoke resolution#4746
liannacasper merged 10 commits intomasterfrom
codex/add-concrete-annotation-to-codename-one

Conversation

@liannacasper
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a class-level hint that a base type maps to a known concrete implementation so the ParparVM translator can avoid virtual dispatch in native pipelines and produce faster C/Objective-C output.
  • Document the new hint in the performance guide to guide users about the tradeoffs and intended use.

Description

  • Add a new annotation com.codename1.annotations.Concrete with a name() element to declare a preferred concrete implementation for ParparVM translation.
  • Annotate CodenameOneImplementation with @Concrete(name = "com.codename1.impl.ios.IOSImplementation") to mark the platform implementation for native targets.
  • Extend ByteCodeClass with a concreteClass field and accessors (getConcreteClass/setConcreteClass) to hold the parsed concrete-class hint.
  • Update Parser to recognize the @Concrete annotation and store the name value (slash-separated) into the ByteCodeClass instance during class parsing.
  • Add resolution logic in CustomInvoke and Invoke so the translator attempts to bind virtual/virtual-like calls to the concrete class method owner (skipping virtual dispatch) when a concrete class is available and when not targeting the JavaScript backend; fall back to the original owner if no concrete implementation provides the method.
  • Update the performance documentation (performance.asciidoc) with a new section describing the @Concrete class-level hint and an example usage.

Testing

  • Ran the translator build and unit tests for the ByteCodeTranslator component; the build and unit tests completed successfully.
  • Performed a full project compile to ensure no regressions in the Java build; compilation succeeded.

Codex Task

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Developer Guide build artifacts are available for download from this workflow run:

Developer Guide quality checks:

  • AsciiDoc linter: No issues found (report)
  • Vale: 14794 alert(s) (1056 errors, 4382 warnings, 9356 suggestions) (exit code 1) (report)
  • Image references: No unused images detected (report)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator

shai-almog commented Apr 14, 2026

Compared 37 screenshots: 37 matched.

Native Android coverage

  • 📊 Line coverage: 7.78% (4095/52607 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.11% (20262/331632), branch 2.91% (930/31974), complexity 3.63% (1113/30630), method 6.38% (913/14308), class 10.58% (201/1899)
    • 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: 7.78% (4095/52607 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 6.11% (20262/331632), branch 2.91% (930/31974), complexity 3.63% (1113/30630), method 6.38% (913/14308), class 10.58% (201/1899)
    • 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 1754.000 ms
Base64 CN1 encode 150.000 ms
Base64 encode ratio (CN1/native) 0.086x (91.4% faster)
Base64 native decode 1506.000 ms
Base64 CN1 decode 169.000 ms
Base64 decode ratio (CN1/native) 0.112x (88.8% faster)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 381 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 9259 ms

  • Hotspots (Top 20 sampled methods):

    • 27.12% java.lang.String.indexOf (441 samples)
    • 20.36% com.codename1.tools.translator.Parser.isMethodUsed (331 samples)
    • 6.58% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (107 samples)
    • 5.66% java.util.ArrayList.indexOf (92 samples)
    • 5.23% java.lang.Object.hashCode (85 samples)
    • 5.17% com.codename1.tools.translator.Parser.addToConstantPool (84 samples)
    • 2.89% com.codename1.tools.translator.BytecodeMethod.optimize (47 samples)
    • 2.64% java.lang.System.identityHashCode (43 samples)
    • 2.09% com.codename1.tools.translator.ByteCodeClass.markDependent (34 samples)
    • 1.78% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (29 samples)
    • 1.60% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (26 samples)
    • 1.48% com.codename1.tools.translator.BytecodeMethod.appendMethodSignatureSuffixFromDesc (24 samples)
    • 0.74% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (12 samples)
    • 0.68% com.codename1.tools.translator.Parser.cullMethods (11 samples)
    • 0.68% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (11 samples)
    • 0.62% com.codename1.tools.translator.ByteCodeClass.markDependencies (10 samples)
    • 0.62% com.codename1.tools.translator.Parser.writeOutput (10 samples)
    • 0.62% sun.nio.fs.UnixNativeDispatcher.open0 (10 samples)
    • 0.62% java.lang.StringBuilder.append (10 samples)
    • 0.49% com.codename1.tools.translator.Parser.getClassByName (8 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

shai-almog commented Apr 14, 2026

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

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
Simulator Boot 1000 ms
Simulator Boot (Run) 0 ms
App Install 2000 ms
App Launch 3000 ms
Test Execution 153000 ms
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 1626.000 ms
Base64 CN1 encode 1407.000 ms
Base64 encode ratio (CN1/native) 0.865x (13.5% faster)
Base64 native decode 733.000 ms
Base64 CN1 decode 1330.000 ms
Base64 decode ratio (CN1/native) 1.814x (81.4% slower)

@liannacasper liannacasper merged commit d9ae900 into master Apr 14, 2026
22 checks passed
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.

2 participants