Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6531561
Device runtime: port the on-device interpreter (#5561) onto master
shai-almog Nov 25, 2026
b674ba1
Device runtime: on-device IDE, Maven push goals, TestFlight readiness
shai-almog Nov 25, 2026
b5fd6cd
Device runtime: push Java 9+ code without a compiler flag; rename to …
shai-almog Nov 26, 2026
8c0fa5b
Codename One Instant: Gradle cn1Push/cn1PushStop tasks, docs for both…
shai-almog Nov 26, 2026
3afc747
Codename One Instant: pinned framework version, mismatch warning, int…
shai-almog Nov 26, 2026
1fa3ebd
Codename One Instant: fix the license header on the two new app classes
shai-almog Nov 26, 2026
f49574e
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Nov 27, 2026
48e533c
Fix CI after merging master
shai-almog Nov 27, 2026
67a6cd9
Interp host: no closed-world devirt or leaf instanceof; CI gates
shai-almog Nov 28, 2026
f4a2605
Codename One Instant: store compliance pass
shai-almog Nov 29, 2026
78864fb
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Nov 29, 2026
0b9e7ac
StoreAudit: accepted findings and a dynamic-code check
shai-almog Nov 29, 2026
7e135e6
Merge origin/master into device-ide; clean up the PR
shai-almog Nov 30, 2026
232e2ad
Device runtime guide: rewrite for users; move internals to the app's …
shai-almog Nov 30, 2026
9aad546
Device runtime guide: drop non-deviations, clarify icon and resources
shai-almog Nov 30, 2026
ba141db
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Nov 30, 2026
00a87df
Fix CI: build hint contraction, guide comma suggestions, self-contain…
shai-almog Nov 30, 2026
5cfadc6
Merge origin/master into device-ide
shai-almog Nov 30, 2026
6cbdb58
Fix master breakage: Hugo removed site.Data; LanguageTool hit in Back…
shai-almog Dec 1, 2026
43edb6c
Merge origin/master into device-ide
shai-almog Dec 1, 2026
65977fe
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Dec 1, 2026
57648c5
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Dec 1, 2026
be382b3
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Dec 1, 2026
5975983
website build: expand an empty array safely under bash 3.2
shai-almog Dec 1, 2026
91410d2
pre-push gates: build the website on JDK 17, as CI does
shai-almog Dec 1, 2026
3d6587a
Instant: point support links at GitHub Discussions
shai-almog Dec 1, 2026
5861989
StoreAudit: catch inert purpose hints, undecided capabilities and pol…
shai-almog Dec 1, 2026
1fe8e20
Merge remote-tracking branch 'origin/master' into device-ide
shai-almog Dec 1, 2026
886a7a8
pre-push gates: build the website against this tree's snapshots, as C…
shai-almog Dec 1, 2026
914d8d6
setup-workspace: re-extract a cached JDK or Maven that lost its binaries
shai-almog Dec 1, 2026
e489fe1
pre-push gates: leave the tree clean after the website build
shai-almog Dec 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ scripts/fidelity-app/common/src/main/resources/iOSModern27Theme.res
scripts/fidelity-app/common/src/main/resources/AndroidMaterialTheme.res
/.m2/

# Local Maven repository used for isolated local builds (see .m2-local)
.m2-local/

# Generated by the device runtime build (see common/pom.xml).
scripts/cn1-device-runtime/common/src/main/java/com/codenameone/devruntime/gen/

# Rendered from maven/build-hint-catalog by scripts/gen-build-hint-table.sh every
# time the developer guide is built. Not checked in: a generated file living in
# git invites a hand edit that the next regeneration silently discards, and needs
Expand Down Expand Up @@ -209,3 +215,5 @@ docs/website/data/port_status_flutter_benchmark.json

# Rendered from vm/selfhost/perf-baseline by scripts/website/build.sh; never committed.
docs/website/data/port_status_jdk25.json
# The Skin Designer bundle scripts/website/build.sh builds into the site.
/docs/website/static/skindesigner-app/
63 changes: 63 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,69 @@ Removals are recorded in the platform's own
bare major -- a query for `removed="37"` matches nothing, while `37.0` and
`37.1` are the real answers. The gate prints the whole set when it fails.

### Device runtime (on-device interpreter)

`scripts/cn1-device-runtime/` is Codename One Instant, the device runtime: an
app with a Java editor that also runs Codename One programs pushed from a
desktop, interpreted rather than compiled. See
`docs/developer-guide/Device-Runtime.asciidoc` (for users) and
`scripts/cn1-device-runtime/INTERNALS.asciidoc` (how it works). Verify on both platforms --
`scripts/run-device-runtime-android.sh <Program.java>` (minutes) and
`scripts/run-device-runtime-ios.sh <Program.java>` (~30 min).

- **A pushed `main` runs on the EDT**, like an app's `start()`. `callSerially`
is legal there, `callSeriallyAndWait` is not.
- **The EDT budget is per entry into the interpreter, not per session.** Every
framework callback is a fresh entry. Measuring from the start of the run makes
the budget expire once and stay expired, killing every later callback -- i.e.
every button press -- with "ran without yielding".
- **Lambdas and method references are desugared** by `InterpLambdaDesugar` when
the bundle is written; neither target can spin a class at run time. Java 9+
string concatenation (`StringConcatFactory`) is rewritten to `StringBuilder`
the same way, so pushed code needs no compiler flag.
- **A linker must dispatch on the receiver's class, not the call site's owner.**
`list.add(x)` compiles to a call naming `java.util.List`; resolving from there
finds `AbstractList.add`, whose body throws `UnsupportedOperationException`.
Android got this free from reflection; iOS resolves the receiver's class id
and walks up from there.
- **`synchronized` uses the real host monitor**, so it interoperates with the
framework and `wait`/`notify` work. A synchronized method wraps the call (on
the peer where there is one); a synchronized block runs its region nested
inside a real `synchronized`, and `monitorexit` returns to the enclosing
level, which is what releases it.
- **A pushed tree's non-`.java` files become resources**, published to
`CodenameOneImplementation` -- not `Display`, which `Resources.openLayered`
never passes through.
- **`java.lang.Enum` has no shim and needs none** -- the interpreter answers
name/ordinal/valueOf itself, since Java forbids naming Enum as a superclass.
- **The device dials out; the desktop listens.** A listening socket inside the
iOS simulator is unreachable from the host. Android needs `adb reverse`, not
`adb forward`. Both runtimes dial the same host port, so a running emulator
app will answer a push meant for the simulator -- the iOS script force-stops
it for exactly this reason.
- **Push from the build tool**: `mvn cn1:push` / `gradle cn1Push` sends the
project's source tree (`cn1:push-stop` ends the run). `scripts/cn1-push.sh
<dir> 18234` does the same for a bare tree with no project, which is what the
probes are. The entry point is discovered -- a `main`, else a `Lifecycle` subclass, which
is what a real app has. `scripts/devruntime-probes/` holds the battery of
programs that found the defects worth knowing about; run it after touching
the interpreter, the linkers or the shims.
- **The shims are generated by the app build** into
`common/target/generated-sources/shims`, never committed. After changing
`GenerateInterpShims`, run `scripts/generate-interp-shims.sh`: it fails if a
shim will not compile (never prune -- that once ate `Interp_ui_Form`), if a
load-bearing shim is missing, or if generating twice differs.
- **The generator reads the device's `java.*` from the `codenameone-java-runtime`
jar with ASM, not by reflecting over the JDK**, and runs under `JAVA17_HOME`.
The two disagree about which methods exist, which are `final`, which
interfaces a class implements, and which constructors exist. Note `javap`
resolves `java.*` from the platform even with `-cp`, so inspect the extracted
`.class` file directly or you will be reading the JDK's copy.
- **Store submission**: listing text in `common/cn1-metadata`
(`mvn cn1:metadata-push`), review notes and history in `store/`. Run the
skill's `StoreAudit.java` in the app before submitting; it must pass with the
app's `store-audit-accepted.txt`, and a finding that does not apply goes there
with its reason, not ignored.
### Build hints

A build hint is a `codename1.arg.<name>=<value>` line the builders read as
Expand Down
47 changes: 47 additions & 0 deletions CodenameOne/src/com/codename1/impl/CodenameOneImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -5234,12 +5234,59 @@ public String[] getNativeSpellingSuggestions(String word, String language, int m
///
/// input stream for the resource or null if not found
public InputStream getResourceAsStream(Class cls, String resource) {
InputStream local = localResource(resource);
if (local != null) {
return local;
}
if (cls != null) {
return cls.getResourceAsStream(resource);
}
return CodenameOneImplementation.class.getResourceAsStream(resource);
}

/// Resources supplied at run time rather than compiled into the app.
///
/// The device runtime pushes a program's own `theme.res`, CSS and images
/// here. They have to be visible from this layer rather than from
/// `Display`, because the calls that matter never pass through `Display`:
/// `Resources.openLayered("/theme")` and `UIManager.initFirstTheme` resolve
/// inside the framework, which asks the implementation directly.
///
/// Empty in an ordinary app, and one emptiness check on a path that
/// already touches the file system. Allocated eagerly rather than lazily:
/// a push arrives on a socket thread while the event thread may be reading,
/// and lazily creating a shared static under that is how entries go missing.
private static final Hashtable localResources = new Hashtable();

/// Publishes a resource under the path an application would load it by,
/// e.g. `/theme.res`. A null value removes it.
public static void setLocalResource(String path, byte[] data) {
if (data == null) {
localResources.remove(path);
} else {
localResources.put(path, data);
}
}

/// Drops every published resource, so a newly pushed program does not
/// inherit the previous one's theme.
public static void clearLocalResources() {
localResources.clear();
}

/// A published resource as a stream, or null. Platform implementations call
/// this before falling back to the classpath.
protected static InputStream localResource(String resource) {
if (resource == null || localResources.isEmpty()) {
return null;
}
byte[] data = (byte[]) localResources.get(resource);
if (data == null && !resource.startsWith("/")) {
data = (byte[]) localResources.get("/" + resource);
}
return data == null ? null : new java.io.ByteArrayInputStream(data);
}

/// Animations should return true to allow the native image animation to update
///
/// #### Parameters
Expand Down
35 changes: 35 additions & 0 deletions CodenameOne/src/com/codename1/impl/interp/InterpBacked.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2026, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/
package com.codename1.impl.interp;

/// Implemented by a generated shim: a framework subclass standing in for an
/// interpreted class.
///
/// Lets the runtime recover the interpreted object from the host-visible peer,
/// which is what makes the round trip work -- interpreted code hands its peer
/// to the framework, the framework hands the peer back to a listener, and the
/// runtime has to get from there to the interpreted instance again.
public interface InterpBacked {
/// The interpreted object this peer stands for.
InterpObject getInterpObject();
}
151 changes: 151 additions & 0 deletions CodenameOne/src/com/codename1/impl/interp/InterpBundle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/*
* Copyright (c) 2026, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/
package com.codename1.impl.interp;

import java.util.Hashtable;

/// A program pushed to the device runtime: the interpreted classes, the symbols
/// they reference in the host app, and the source the user wrote.
///
/// The bundle is produced on the developer's machine (see the translator's
/// `InterpBundleWriter`) and consumed by [InterpRuntime]. Nothing here parses a
/// class file: the constant pool is already resolved into flat tables and jump
/// targets are already instruction indices, so the device only walks arrays.
///
/// The IR deliberately keeps the JVM's own opcodes rather than inventing a new
/// instruction set. Every semantic question -- what `dup2` does to a category-2
/// value, when `athrow` unwinds, how `invokespecial` differs from
/// `invokevirtual` -- then has one authoritative answer instead of a
/// reinterpretation that has to be rediscovered by testing. What the IR removes
/// is only the parts a device should not pay for: constant-pool lookups, symbol
/// resolution and label arithmetic.
public final class InterpBundle {
/// Magic word at the head of every bundle: 'C','N','1','I'.
public static final int MAGIC = 0x434E3149;

/// Bundle format version. The runtime refuses anything it does not know,
/// because a bundle is pushed from a machine whose SDK moves independently
/// of the installed app.
///
/// Bumped to 4 when LDC_DOUBLE constants switched from a `Double.toString`
/// encoding to raw long bits: an older reader would call
/// `Double.parseDouble` on the new encoding and fail on a value like
/// "4607182418800017408" (the bits of 1.0).
///
/// Bumped to 5 when static field rows started carrying the ConstantValue
/// attribute (a tag byte + typed value): older bundles left a
/// `static final X = 42` reading as 0 through GETSTATIC because javac's
/// inlining does not run for a caller compiled against an earlier
/// non-final version.
///
/// Bumped to 6 when the header started carrying the Codename One version
/// the program was compiled against, right after the main class. It sits
/// inside the authenticated body, so a device can trust it when it warns
/// about a desktop on a different version.
public static final int VERSION = 6;

/// Extern kinds -- what a reference into the host app names.
public static final int EXTERN_CLASS = 0;
public static final int EXTERN_METHOD = 1;
public static final int EXTERN_FIELD = 2;

String[] strings;

/// Parallel arrays over the extern table. For a method or field, owner/name/
/// desc are string-pool indices; for a class only owner is meaningful.
int[] externKind;
int[] externOwner;
int[] externName;
int[] externDesc;

/// Resolved lazily by the linker, so a program that never touches a symbol
/// never pays to resolve it -- and never fails because of it.
Object[] externResolved;
boolean[] externResolveAttempted;

InterpClass[] classes;

/// Interpreted class name -> InterpClass, in JVM internal form (a/b/C).
Hashtable classesByName = new Hashtable();

/// Source file name -> source text. Mandatory: the runtime refuses a bundle
/// whose interpreted classes are not all covered, because the App Store's
/// educational-code allowance is conditional on the user being able to see
/// and edit what runs (guideline 2.5.2).
Hashtable sources = new Hashtable();

/// The program's own resources -- theme.res, CSS, images -- keyed by the
/// path an application loads them by. Handed to the implementation layer
/// when the bundle is loaded, so `Resources.openLayered("/theme")` finds
/// the pushed program's theme rather than the runtime host's.
Hashtable resources = new Hashtable();

String mainClass;
String frameworkVersion;

InterpBundle() {
}

/// The string pool entry at the given index.
public String string(int index) {
return strings[index];
}

/// The interpreted class with this JVM internal name, or null if the class
/// is not part of this bundle (i.e. it belongs to the host app).
public InterpClass findClass(String internalName) {
return (InterpClass) classesByName.get(internalName);
}

/// The interpreted classes in this bundle.
public InterpClass[] getClasses() {
return classes;
}

/// The class whose main method the runtime should enter, or null when the
/// bundle is a library rather than a program.
public String getMainClass() {
return mainClass;
}

/// The Codename One version the sending desktop compiled against, or null
/// when it did not say (the on-device editor, a tool that does not know).
public String getFrameworkVersion() {
return frameworkVersion;
}

/// The source text for a file name, or null. Used by the on-device viewer.
public String getSource(String fileName) {
return (String) sources.get(fileName);
}

/// The names of every source file carried by this bundle.
public java.util.Enumeration getSourceFileNames() {
return sources.keys();
}

/// The resources this bundle carries, keyed by load path.
public Hashtable getResources() {
return resources;
}
}
Loading
Loading