René's URL Explorer Experiment


Title: feat: support native ES classes with lazy registration by NathanWalker · Pull Request #1983 · NativeScript/android · GitHub

Open Graph Title: feat: support native ES classes with lazy registration by NathanWalker · Pull Request #1983 · NativeScript/android

X Title: feat: support native ES classes with lazy registration by NathanWalker · Pull Request #1983 · NativeScript/android

Description: Parity with NativeScript/ios#403 Makes plain ES2015+ classes that extend native types work directly on Android, without requiring @NativeClass or ES5 downleveling: class JSClass extends android.view.View { toString() { return 'hello from ES class'; } } Lazy registration Construction is not the only way a class first crosses into native code. All of the following now trigger lazy registration, before any instance has ever been created: class JSClass extends java.lang.Object {} someNativeMethod(JSClass); // passed as a Class (or Object) argument JSClass.class; // .class before any construction JSClass.class.newInstance(); // Java reflection constructs the proxy JSClass.STATIC_FIELD; // inherited static field JSClass.someStaticMethod(); // inherited static method dispatch Instance identity new MyClass() and Java-born construction (Class.newInstance(), view inflation, framework construction) now produce the same kind of JS instance: a real construct of the ES class. Public fields, private fields (#a), and the constructor body run on both paths. The constructor → super() loop is broken with an isolate-local adopt slot (PendingESAdoptObjectId): Java already created object N1. CreateJSInstanceNative(N1) stashes N1's id and constructs MyClass. super() binds this to N1 and does not NewObject again. super(args) stays the create-path constructor picker. Adopt ignores those args so the Java constructor that already ran stays authoritative. class MyClass extends com.tns.tests.DummyClass { #a = 1; constructor() { super('from-super'); } someMethod() { return this.#a; } } new MyClass().someMethod(); // 1, nameField === 'from-super' MyClass.class.newInstance().someMethod(); // 1, nameField === 'dummy' (no-arg Java ctor) Not solved here (not deal-breakers): Constructors that require JS-only arguments cannot be invented on the native-born path (CreateJSInstanceNative constructs with zero args). JS-only methods still need to be named as Java overrides (or listed for the DexFactory scan) to be callable via invokevirtual. A constructor that throws after super() leaves a partial JS↔Java link; a later wrap of the same id does not construct again. Worker isolates: NativeClass and ES class registration are a no-op. Only the main isolate mints native subclasses. Legacy .extend() is unchanged. NativeClass decorator API @NativeClass is no longer a no-op. Optional android options map to the existing statics and can eagerly name the Java proxy class: @NativeClass({ android: { interfaces: [java.lang.Runnable], name: 'org.nativescript.example.CustomActivity', }, // accepted and ignored on this runtime ios: { name: 'MyNeatIOSClass', protocols: [UIDelegateAnything], }, }) class MyClass extends android.view.View {} All properties are optional. android.interfaces → static interfaces android.name → static nativeClassName plus eager registration via .class This runtime implements android only; ios is accepted and ignored @NativeClass and @NativeClass({ android: { … } }) are both valid. Passing the class directly (NativeClass(MyClass)) applies empty options. On worker isolates this is a no-op. Tests See test-app/app/src/main/assets/app/tests/testNativeESClasses.js, including: lazy .class / Class marshalling before construction Java virtual dispatch into ES overrides and super multi-level ES inheritance When_java_instantiates_an_es_class_the_js_constructor_and_fields_should_run When_java_instantiates_an_es_class_private_fields_should_be_readable When_java_instantiates_an_es_class_super_args_should_not_construct_again When_an_es_class_constructor_throws_both_paths_should_surface_the_error When_the_NativeClass_decorator_is_applied_it_should_apply_android_options When_NativeClass_sets_an_android_name_the_proxy_should_register_immediately When_NativeClass_runs_on_a_worker_it_should_be_a_noop Summary by CodeRabbit New Features Added support for extending native Java classes and interfaces with modern JavaScript ES classes. Added lazy native proxy registration and improved class and constructor marshalling. Added support for static members, private fields, super calls, constructor forwarding, and Java-created ES-class instances. Added the global NativeClass decorator with interface and explicit naming options. Bug Fixes Prevented duplicate superclass construction and improved constructor error propagation. Preserved compatibility with legacy .extend() classes while rejecting unsupported ES-class usage.

Open Graph Description: Parity with NativeScript/ios#403 Makes plain ES2015+ classes that extend native types work directly on Android, without requiring @NativeClass or ES5 downleveling: class JSClass extends android.vie...

X Description: Parity with NativeScript/ios#403 Makes plain ES2015+ classes that extend native types work directly on Android, without requiring @NativeClass or ES5 downleveling: class JSClass extends android.vie...

Opengraph URL: https://github.com/NativeScript/android/pull/1983

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8db60737-70fc-91ea-e343-c543f2435835
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCD72:3C21B:185904A:1F250AE:6B01314E
html-safe-nonceca4933d8e81260dc8bdaaa38198c6be94c118f51a7c4a0661cd6bc9d4592ab1b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDcyOjNDMjFCOjE4NTkwNEE6MUYyNTBBRTo2QjAxMzE0RSIsInZpc2l0b3JfaWQiOiI4MDYyODM1NTgyNzk3MTY0ODc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb17a4b7a1e3dbfd9addf6d34839cf30d44c0823d37d9d50f0563064c0a2c0ea4
hovercard-subject-tagpull_request:4071067552
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/NativeScript/android/pull/1983/files
twitter:imagehttps://avatars.githubusercontent.com/u/457187?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/457187?s=400&v=4
og:image:altParity with NativeScript/ios#403 Makes plain ES2015+ classes that extend native types work directly on Android, without requiring @NativeClass or ES5 downleveling: class JSClass extends android.vie...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/NativeScript/android git https://github.com/NativeScript/android.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id29137950
octolytics-dimension-repository_nwoNativeScript/android
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id29137950
octolytics-dimension-repository_network_root_nwoNativeScript/android
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/NativeScript/android/pull/1983/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fpull%2F1983%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fpull%2F1983%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=NativeScript%2Fandroid
Reloadhttps://github.com/NativeScript/android/pull/1983/files
Reloadhttps://github.com/NativeScript/android/pull/1983/files
Reloadhttps://github.com/NativeScript/android/pull/1983/files
NativeScripthttps://github.com/NativeScript
androidhttps://github.com/NativeScript/android
Codehttps://github.com/NativeScript/android
Issues106 (106)https://github.com/NativeScript/android/issues
Pull requests24 (24)https://github.com/NativeScript/android/pulls
Actionshttps://github.com/NativeScript/android/actions
Projectshttps://github.com/NativeScript/android/projects
Wikihttps://github.com/NativeScript/android/wiki
Security and qualityhttps://github.com/NativeScript/android/security
Insightshttps://github.com/NativeScript/android/insights
Sign up for GitHub https://github.com/signup?return_to=%2FNativeScript%2Fandroid%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FNativeScript%2Fandroid%2Fissues%2Fnew%2Fchoose
NathanWalkerhttps://github.com/NathanWalker
mainhttps://github.com/NativeScript/android/tree/main
feat/native-es-classeshttps://github.com/NativeScript/android/tree/feat/native-es-classes
Conversation 17 https://github.com/NativeScript/android/pull/1983
Commits 4 https://github.com/NativeScript/android/pull/1983/commits
Checks 7 https://github.com/NativeScript/android/pull/1983/checks
Files changed 12 https://github.com/NativeScript/android/pull/1983/files
feat: support native ES classes with lazy registration https://github.com/NativeScript/android/pull/1983/files#top
Show all changes 4 commits https://github.com/NativeScript/android/pull/1983/files
3f7aa5e feat: support native ES classes with lazy registration NathanWalker Jul 16, 2026 https://github.com/NativeScript/android/pull/1983/commits/3f7aa5e79912ecfa7e76e7ccc2d1a98c881ae5eb
033b682 feat: adopt native-born ES class instances into a real construct NathanWalker Aug 14, 2026 https://github.com/NativeScript/android/pull/1983/commits/033b6823a879a9fc872da1abd9f5132a3b03d138
7d150a7 chore: pr feedback NathanWalker Aug 15, 2026 https://github.com/NativeScript/android/pull/1983/commits/7d150a71f6c7be9c1c20bb1a906cd4be2a0348b9
a85598a ci: unit test fixes NathanWalker Aug 15, 2026 https://github.com/NativeScript/android/pull/1983/commits/a85598ae2ffb5cecfd3ff6ff60a708967f37ed8e
Clear filters https://github.com/NativeScript/android/pull/1983/files
Please reload this pagehttps://github.com/NativeScript/android/pull/1983/files
Please reload this pagehttps://github.com/NativeScript/android/pull/1983/files
mainpage.js https://github.com/NativeScript/android/pull/1983/files#diff-b7fd6c22bfc29391e9e3ed935d6c6194b1ad595c7592690229952b5ddb99c0d5
testNativeESClasses.js https://github.com/NativeScript/android/pull/1983/files#diff-01acc1bdda9f28dd092cfe71c039cdd2740f15da937b32d034d9964b9ae31fac
ts_helpers.js https://github.com/NativeScript/android/pull/1983/files#diff-73c2ec999b46fd4a1adf5ae87fd5576c03f1c54db424e3941688b04430a39c60
CallbackHandlers.cpp https://github.com/NativeScript/android/pull/1983/files#diff-a784229ab7689cd9ce3d502557091158b2943269fad47c1891a15a07c355500e
CallbackHandlers.h https://github.com/NativeScript/android/pull/1983/files#diff-1f7b413d95b12ea3b982950185ce4f7e56c5c02952d656a5dcc0ff8878e37722
JsArgConverter.cpp https://github.com/NativeScript/android/pull/1983/files#diff-9b41f905739990783e7f543f4c38aab34593873cf03762c959d6c3c7b6e991b7
JsArgToArrayConverter.cpp https://github.com/NativeScript/android/pull/1983/files#diff-2893b81a974ae0a84357d112dd872c8c7f3f3c74342ed15f25596e8f928e6ebf
MetadataNode.cpp https://github.com/NativeScript/android/pull/1983/files#diff-6f6c5b64f60875e24b75b8a21b3164f114822aa7e5add5755f072f36403f7f8b
MetadataNode.h https://github.com/NativeScript/android/pull/1983/files#diff-ac7f7c34025389ca6f1145667245073945ad1bc6b2b1285a05bf4d084924f091
Runtime.cpp https://github.com/NativeScript/android/pull/1983/files#diff-b9490640f5d26f7cd6b9a176a2142b8e985a6aac9e2d64287de37fc694e80cc3
Runtime.h https://github.com/NativeScript/android/pull/1983/files#diff-87f802d33bb6047fdb5ef6dc8d73551485ecb092edff4de77ecc9affc3e9341c
DexFactory.java https://github.com/NativeScript/android/pull/1983/files#diff-7f8ef213b415ed89638d410cdc1813a95a7aafb2b6ae962e4862099ae1a8f95d
test-app/app/src/main/assets/app/mainpage.jshttps://github.com/NativeScript/android/pull/1983/files#diff-b7fd6c22bfc29391e9e3ed935d6c6194b1ad595c7592690229952b5ddb99c0d5
View file https://github.com/NativeScript/android/blob/a85598ae2ffb5cecfd3ff6ff60a708967f37ed8e/test-app/app/src/main/assets/app/mainpage.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/NativeScript/android/pull/1983/{{ revealButtonHref }}
https://github.com/NativeScript/android/pull/1983/files#diff-b7fd6c22bfc29391e9e3ed935d6c6194b1ad595c7592690229952b5ddb99c0d5
https://github.com/NativeScript/android/pull/1983/files#diff-b7fd6c22bfc29391e9e3ed935d6c6194b1ad595c7592690229952b5ddb99c0d5
Please reload this pagehttps://github.com/NativeScript/android/pull/1983/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.