Skip to content

Support nested POSIX classes ([[:alpha:]]) in RE and add Character helper APIs; expand regex tests#4598

Merged
shai-almog merged 1 commit intomasterfrom
codex/add-re-class-support-for-alpha-regex
Mar 6, 2026
Merged

Support nested POSIX classes ([[:alpha:]]) in RE and add Character helper APIs; expand regex tests#4598
shai-almog merged 1 commit intomasterfrom
codex/add-re-class-support-for-alpha-regex

Conversation

@shai-almog
Copy link
Collaborator

Motivation

  • The RE engine did not recognize the standard nested POSIX character-class form like [[:alpha:]], so patterns such as RE("list [[:alpha:]]*") failed to work.
  • The regex engine needs small Character helper APIs to expose alpha/numeric/alphanumeric checks on the platform API surface so the regex code can rely on them consistently across VM and CLDC11.

Description

  • Added parsing and handling for both [:class:] and nested [[:class:]] POSIX character-class forms in RECompiler by introducing parsePosixCharacterClass(...) and wiring detection for the two forms in characterClass() (file: CodenameOne/src/com/codename1/util/regex/RECompiler.java).
  • Added Character convenience APIs to the VM Java API implementation: isAlpha(char|int), isNumeric(char|int), and isAlphaNumeric(char|int) (file: vm/JavaAPI/src/java/lang/Character.java).
  • Added matching CLDC11 API surface methods isAlpha(char), isNumeric(char), and isAlphaNumeric(char) so the methods exist in the CLDC11 API (file: Ports/CLDC11/src/java/lang/Character.java).
  • Expanded the regex unit test RETest with coverage for nested POSIX classes, legacy [:alpha:] behavior, and additional POSIX classes and escapes (alnum, digit, xdigit, \w, \s, \d) (file: maven/core-unittests/src/test/java/com/codename1/util/regex/RETest.java).

Testing

  • Ran the specific regex unit tests with Maven: cd maven && mvn -pl core-unittests -am -DunitTests=true -Dmaven.javadoc.skip=true -DfailIfNoTests=false test -Dtest=com.codename1.util.regex.RETest and the updated RETest suite ran and passed (5 tests, 0 failures).
  • An earlier run surfaced environment differences (missing local-dev-javase profile and the JDK path noted in repository documentation), so the final verification used the project test invocation above and completed successfully.

Codex Task

@github-actions
Copy link

github-actions bot commented Mar 6, 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 6, 2026

Compared 32 screenshots: 32 matched.

Native Android coverage

  • 📊 Line coverage: 7.31% (3716/50867 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.71% (18263/320093), branch 2.76% (858/31113), complexity 3.42% (1017/29746), method 6.01% (833/13858), class 9.83% (180/1831)
    • 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)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 7.31% (3716/50867 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 5.71% (18263/320093), branch 2.76% (858/31113), complexity 3.42% (1017/29746), method 6.01% (833/13858), class 9.83% (180/1831)
    • 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 6, 2026

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 146 total, 0 failed, 2 skipped

Benchmark Results

  • Execution Time: 9694 ms

  • Hotspots (Top 20 sampled methods):

    • 19.61% java.lang.String.indexOf (336 samples)
    • 18.16% com.codename1.tools.translator.Parser.isMethodUsed (311 samples)
    • 17.92% java.util.ArrayList.indexOf (307 samples)
    • 7.47% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (128 samples)
    • 4.79% java.lang.Object.hashCode (82 samples)
    • 4.03% com.codename1.tools.translator.ByteCodeClass.calcUsedByNative (69 samples)
    • 2.98% java.lang.System.identityHashCode (51 samples)
    • 1.75% com.codename1.tools.translator.BytecodeMethod.optimize (30 samples)
    • 1.63% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (28 samples)
    • 1.34% com.codename1.tools.translator.ByteCodeClass.markDependent (23 samples)
    • 1.34% java.lang.StringBuilder.append (23 samples)
    • 1.05% com.codename1.tools.translator.Parser.cullMethods (18 samples)
    • 0.93% sun.nio.fs.UnixNativeDispatcher.open0 (16 samples)
    • 0.82% com.codename1.tools.translator.BytecodeMethod.appendMethodC (14 samples)
    • 0.82% java.lang.StringCoding.encode (14 samples)
    • 0.76% sun.nio.ch.FileDispatcherImpl.write0 (13 samples)
    • 0.64% com.codename1.tools.translator.Parser.getClassByName (11 samples)
    • 0.53% java.io.FileOutputStream.writeBytes (9 samples)
    • 0.53% com.codename1.tools.translator.ByteCodeClass.isDefaultInterfaceMethod (9 samples)
    • 0.53% com.codename1.tools.translator.BytecodeMethod.isMethodUsedByNative (9 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
Collaborator Author

shai-almog commented Mar 6, 2026

iOS screenshot updates

Compared 32 screenshots: 31 matched, 1 updated.

  • landscape — updated screenshot. Screenshot differs (2556x1179 px, bit depth 8).

    landscape
    Preview info: Preview provided by instrumentation.
    Full-resolution PNG saved as landscape.png in workflow artifacts.

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
Simulator Boot 2000 ms
Simulator Boot (Run) 3000 ms
App Install 3000 ms
App Launch 5000 ms
Test Execution 142000 ms

@shai-almog shai-almog merged commit 5cdc9d1 into master Mar 6, 2026
16 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.

1 participant