Skip to content

Fix JavaScript port pipeline: guard initImpl against getClass/getName failures in ParparVM translation#4719

Merged
shai-almog merged 1 commit intojavascript-port-initial-workfrom
copilot/fix-javascript-port-pipeline
Apr 7, 2026
Merged

Fix JavaScript port pipeline: guard initImpl against getClass/getName failures in ParparVM translation#4719
shai-almog merged 1 commit intojavascript-port-initial-workfrom
copilot/fix-javascript-port-pipeline

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

The JavaScript pipeline times out waiting for CN1SS:SUITE:FINISHED because a TypeError: Cannot read properties of null (reading '__classDef') during Display.init() kills the main thread in the ParparVM drain scheduler. The error originates in CodenameOneImplementation.initImpl(Object m) which calls m.getClass().getName() then substring(0, lastIndexOf('.')) — in the ParparVM JS translation, getClass() can return null or getName() returns underscore-separated names with no dots, and the resulting TypeError bypasses Java catch(Throwable) blocks (which only catch Java exceptions, not raw JS errors).

Changes

  • port.js — Added bindCiFallback shim for initImpl that wraps the original method; on __classDef/substring/lastIndexOf errors, recovers by deriving packageName from the object's __class metadata and setting the initiailized flag directly (note: field name matches the existing typo in CodenameOneImplementation.java:158)

  • ParparVMBootstrap.java — Simplified bootstrap() to match JavaScriptPortBootstrap.bootstrap() structure. Removed hasNativeTheme()/installNativeTheme() calls between Display.init() and bootstrap.run() that made additional virtual dispatch calls on partially-initialized state

  • Root ParparVMBootstrap.java — Deleted bogus file with wrong imports (com.codename1.impl.javase.HTML5Implementation)

Key detail: why Java catch doesn't help

The ParparVM drain() scheduler runs generators via thread.generator.next() inside a JS-level try/catch. A raw TypeError from null virtual dispatch (obj.__classDef) is not a Java Throwable — it has no __class/__classDef properties — so translated catch(Throwable) blocks rethrow it, and it propagates to drain() which calls jvm.fail(err) and abandons the thread.

…remove bogus file

- Add port.js shim for CodenameOneImplementation.initImpl to handle
  getClass().getName() failures in ParparVM JS translation
- Simplify ParparVMBootstrap.bootstrap() to match JavaScriptPortBootstrap
  (remove intermediate hasNativeTheme/installNativeTheme calls)
- Remove bogus root-level ParparVMBootstrap.java with incorrect imports
- Update STATUS.md with fix descriptions

Agent-Logs-Url: https://github.com/codenameone/CodenameOne/sessions/450e96a0-a954-4d81-b2c3-4743d2b2bbe3

Co-authored-by: shai-almog <67850168+shai-almog@users.noreply.github.com>
@shai-almog shai-almog marked this pull request as ready for review April 7, 2026 18:57
@shai-almog shai-almog merged commit 17e2f40 into javascript-port-initial-work Apr 7, 2026
@shai-almog shai-almog deleted the copilot/fix-javascript-port-pipeline branch April 7, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants