From 959e582fb6e07760a10fb43b53e2efb4cde1132a Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Thu, 28 May 2026 09:58:26 +0300 Subject: [PATCH 1/2] Fix bytecode compliance check crash on project class references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cn1:compliance-check goal (now bytecode-compliance) crashed when an invocation rewrite (String.split / replaceAll / replaceFirst) was applied to a class that referenced a sibling project class. ASM's CheckClassAdapter .verify was called without a ClassLoader, so SimpleVerifier fell back to Class.forName on the plugin classloader, which doesn't see user project classes, producing a TypeNotPresentException / ClassNotFoundException and failing the build. Pass a URLClassLoader that spans the project's output dir plus compile -scope dependency jars, and treat any remaining unresolvable types as a debug-level skip rather than a build failure — the verify is only a sanity check on our rewrite; the real compliance scan and the cloud build still catch genuine API misuse. Also migrates all internal POMs, archetypes, initializr templates, and the cn1lib lifecycle binding off the deprecated compliance-check alias to the new bytecode-compliance goal, so fresh initializr projects no longer print the deprecation warning. The alias remains for backward compatibility with older user projects, with a cleaned-up deprecation message. Co-Authored-By: Claude Opus 4.7 (1M context) --- docs/demos/common/pom.xml | 2 +- .../archetype-resources/common/pom.xml | 2 +- .../archetype-resources/common/pom.xml | 4 +- .../maven/BytecodeComplianceMojo.java | 100 +++++++++++++++--- .../codename1/maven/ComplianceCheckMojo.java | 2 +- .../resources/META-INF/plexus/components.xml | 2 +- maven/tests/core-tests/pom.xml | 2 +- maven/tests/signindemo/pom.xml | 2 +- maven/tests/testnativeinterfaces/pom.xml | 2 +- scripts/cn1playground/common/pom.xml | 2 +- .../src/main/resources/barebones-pom.xml | 2 +- scripts/hellocodenameone/common/pom.xml | 2 +- scripts/initializr/common/pom.xml | 2 +- .../src/main/resources/barebones-pom.xml | 2 +- .../common/src/main/resources/grub-pom.xml | 2 +- .../common/src/main/resources/kotlin-pom.xml | 2 +- .../common/src/main/resources/skill/SKILL.md | 2 +- .../resources/skill/references/cn1libs.md | 2 +- .../skill/references/java-api-subset.md | 4 +- .../src/main/resources/skill/tools/README.md | 2 +- .../common/src/main/resources/tweet-pom.xml | 2 +- scripts/skindesigner/common/pom.xml | 2 +- 22 files changed, 109 insertions(+), 37 deletions(-) diff --git a/docs/demos/common/pom.xml b/docs/demos/common/pom.xml index 4d7bf72b2a..833822345e 100644 --- a/docs/demos/common/pom.xml +++ b/docs/demos/common/pom.xml @@ -344,7 +344,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml index f6c1c3bd14..2647198ae9 100644 --- a/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml +++ b/maven/cn1app-archetype/src/main/resources/archetype-resources/common/pom.xml @@ -382,7 +382,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/cn1playground/common/src/main/resources/barebones-pom.xml b/scripts/cn1playground/common/src/main/resources/barebones-pom.xml index 45b112c92d..9db90693d6 100644 --- a/scripts/cn1playground/common/src/main/resources/barebones-pom.xml +++ b/scripts/cn1playground/common/src/main/resources/barebones-pom.xml @@ -350,7 +350,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/hellocodenameone/common/pom.xml b/scripts/hellocodenameone/common/pom.xml index a07cf852e9..ab7eda795f 100644 --- a/scripts/hellocodenameone/common/pom.xml +++ b/scripts/hellocodenameone/common/pom.xml @@ -357,7 +357,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css process-annotations diff --git a/scripts/initializr/common/pom.xml b/scripts/initializr/common/pom.xml index 4fde35c158..6a217c55cc 100644 --- a/scripts/initializr/common/pom.xml +++ b/scripts/initializr/common/pom.xml @@ -366,7 +366,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/initializr/common/src/main/resources/barebones-pom.xml b/scripts/initializr/common/src/main/resources/barebones-pom.xml index 5367184adb..00902d8594 100644 --- a/scripts/initializr/common/src/main/resources/barebones-pom.xml +++ b/scripts/initializr/common/src/main/resources/barebones-pom.xml @@ -354,7 +354,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/initializr/common/src/main/resources/grub-pom.xml b/scripts/initializr/common/src/main/resources/grub-pom.xml index dabd70663a..bcbf61f9d1 100644 --- a/scripts/initializr/common/src/main/resources/grub-pom.xml +++ b/scripts/initializr/common/src/main/resources/grub-pom.xml @@ -357,7 +357,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/initializr/common/src/main/resources/kotlin-pom.xml b/scripts/initializr/common/src/main/resources/kotlin-pom.xml index ca92d3951f..51f4bbeef1 100644 --- a/scripts/initializr/common/src/main/resources/kotlin-pom.xml +++ b/scripts/initializr/common/src/main/resources/kotlin-pom.xml @@ -350,7 +350,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/initializr/common/src/main/resources/skill/SKILL.md b/scripts/initializr/common/src/main/resources/skill/SKILL.md index d6f730b088..081dc86f46 100644 --- a/scripts/initializr/common/src/main/resources/skill/SKILL.md +++ b/scripts/initializr/common/src/main/resources/skill/SKILL.md @@ -73,7 +73,7 @@ This project targets **Java 17** (`17` / `17` - `switch` expressions - Lambdas, method references, `Stream`s -**Caveat — the build server cross-compiles to bytecode that ParparVM/TeaVM can consume.** Codename One ships a curated subset of the JDK, **not** the full `java.*` namespace. The `cn1:compliance-check` Maven goal runs on every compile and fails the build if you call an unsupported API. The most common gotchas: +**Caveat — the build server cross-compiles to bytecode that ParparVM/TeaVM can consume.** Codename One ships a curated subset of the JDK, **not** the full `java.*` namespace. The `cn1:bytecode-compliance` Maven goal runs on every compile and fails the build if you call an unsupported API. The most common gotchas: - No `java.nio.file.*` — use `com.codename1.io.FileSystemStorage` and `Storage`. - No `java.net.http.*` / `java.net.URLConnection` — use `com.codename1.io.rest.Rest` (preferred) or `ConnectionRequest`. diff --git a/scripts/initializr/common/src/main/resources/skill/references/cn1libs.md b/scripts/initializr/common/src/main/resources/skill/references/cn1libs.md index 99d36e3f1e..745592283c 100644 --- a/scripts/initializr/common/src/main/resources/skill/references/cn1libs.md +++ b/scripts/initializr/common/src/main/resources/skill/references/cn1libs.md @@ -44,7 +44,7 @@ Run `mvn -pl common compile` and the CN1 plugin scans `cn1libs/`, unpacks each f To verify a cn1lib is wired in correctly, run the bytecode compliance check — it scans all dependencies and will fail noisily if a class is missing: ```bash -mvn -pl common compile cn1:compliance-check +mvn -pl common compile cn1:bytecode-compliance ``` ## Creating a new cn1lib (Maven) diff --git a/scripts/initializr/common/src/main/resources/skill/references/java-api-subset.md b/scripts/initializr/common/src/main/resources/skill/references/java-api-subset.md index 7077f98bcf..23656cf5f5 100644 --- a/scripts/initializr/common/src/main/resources/skill/references/java-api-subset.md +++ b/scripts/initializr/common/src/main/resources/skill/references/java-api-subset.md @@ -1,12 +1,12 @@ # Java API Subset, IO, and Networking -Codename One does **not** ship with the full JDK. The Java code you write in `common/` is cross-compiled by ParparVM (iOS) and TeaVM (web), and runs on Android against a hand-curated JDK subset. If you call a class or method that isn't in the subset, the cloud build fails the **compliance check** (`cn1:compliance-check`, which the `process-classes` phase runs automatically). +Codename One does **not** ship with the full JDK. The Java code you write in `common/` is cross-compiled by ParparVM (iOS) and TeaVM (web), and runs on Android against a hand-curated JDK subset. If you call a class or method that isn't in the subset, the cloud build fails the **bytecode compliance check** (`cn1:bytecode-compliance`, which the `process-classes` phase runs automatically). This document tells you (1) how to discover what *is* supported, and (2) where the IO and networking APIs differ from standard Java. ## How to discover the supported API -The supported API surface is defined by two artifacts that the Codename One Maven plugin resolves from Maven Central. The `compliance-check` goal compares your compiled bytecode against both jars and fails on anything not present. +The supported API surface is defined by two artifacts that the Codename One Maven plugin resolves from Maven Central. The `bytecode-compliance` goal compares your compiled bytecode against both jars and fails on anything not present. | Artifact | What's inside | | --- | --- | diff --git a/scripts/initializr/common/src/main/resources/skill/tools/README.md b/scripts/initializr/common/src/main/resources/skill/tools/README.md index 2dba7ca87d..1c3e3f491f 100644 --- a/scripts/initializr/common/src/main/resources/skill/tools/README.md +++ b/scripts/initializr/common/src/main/resources/skill/tools/README.md @@ -27,7 +27,7 @@ java tools/IsApiSupported.java java.util.HashMap#put # YES (class present at java-runtime-7.0.242.jar!java/util/HashMap.class — for method-level confirmation run `javap -p -classpath …` and grep for `put`) ``` -Useful when porting code from desktop Java and you want a quick "is this safe to use" check before discovering it at `mvn cn1:compliance-check` time. +Useful when porting code from desktop Java and you want a quick "is this safe to use" check before discovering it at `mvn cn1:bytecode-compliance` time. For the full picture of what's supported and what isn't, see `references/java-api-subset.md`. diff --git a/scripts/initializr/common/src/main/resources/tweet-pom.xml b/scripts/initializr/common/src/main/resources/tweet-pom.xml index bb6d73b787..cb8f999963 100644 --- a/scripts/initializr/common/src/main/resources/tweet-pom.xml +++ b/scripts/initializr/common/src/main/resources/tweet-pom.xml @@ -369,7 +369,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css diff --git a/scripts/skindesigner/common/pom.xml b/scripts/skindesigner/common/pom.xml index 8d2e1d170a..5e77cdd994 100644 --- a/scripts/skindesigner/common/pom.xml +++ b/scripts/skindesigner/common/pom.xml @@ -357,7 +357,7 @@ cn1-process-classes process-classes - compliance-check + bytecode-compliance css From 170ce953dacd5b2819c5e7bc52cb486792289207 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Thu, 28 May 2026 10:16:09 +0300 Subject: [PATCH 2/2] Revert goal rename in POMs that pin to older plugin versions docs/demos pins to codenameone-maven-plugin 7.0.208 and scripts/skindesigner pins to 7.0.228; neither has the bytecode-compliance goal yet. Keep them on the compliance-check alias. Co-Authored-By: Claude Opus 4.7 (1M context) --- docs/demos/common/pom.xml | 2 +- scripts/skindesigner/common/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/demos/common/pom.xml b/docs/demos/common/pom.xml index 833822345e..4d7bf72b2a 100644 --- a/docs/demos/common/pom.xml +++ b/docs/demos/common/pom.xml @@ -344,7 +344,7 @@ cn1-process-classes process-classes - bytecode-compliance + compliance-check css diff --git a/scripts/skindesigner/common/pom.xml b/scripts/skindesigner/common/pom.xml index 5e77cdd994..8d2e1d170a 100644 --- a/scripts/skindesigner/common/pom.xml +++ b/scripts/skindesigner/common/pom.xml @@ -357,7 +357,7 @@ cn1-process-classes process-classes - bytecode-compliance + compliance-check css