Title: Reading `SomeClass.null` permanently breaks that class's static `valueOf()` · Issue #1986 · NativeScript/android · GitHub
Open Graph Title: Reading `SomeClass.null` permanently breaks that class's static `valueOf()` · Issue #1986 · NativeScript/android
X Title: Reading `SomeClass.null` permanently breaks that class's static `valueOf()` · Issue #1986 · NativeScript/android
Description: Summary Reading the typed-null marker SomeJavaClass.null permanently breaks SomeJavaClass.valueOf(...) for the remaining life of the isolate — it silently starts returning null for every argument. The .null getter deletes the class's Jav...
Open Graph Description: Summary Reading the typed-null marker SomeJavaClass.null permanently breaks SomeJavaClass.valueOf(...) for the remaining life of the isolate — it silently starts returning null for every argument. ...
X Description: Summary Reading the typed-null marker SomeJavaClass.null permanently breaks SomeJavaClass.valueOf(...) for the remaining life of the isolate — it silently starts returning null for every argument. ...
Opengraph URL: https://github.com/NativeScript/android/issues/1986
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reading `SomeClass.null` permanently breaks that class's static `valueOf()`","articleBody":"### Summary\n\nReading the typed-null marker `SomeJavaClass.null` **permanently breaks `SomeJavaClass.valueOf(...)`** for the remaining life of the isolate — it silently starts returning `null` for every argument.\n\nThe `.null` getter deletes the class's Java static `valueOf` and replaces it with an internal shim that unconditionally returns null. Because the marker object *is* the constructor function itself, that shim lands directly on the class.\n\nThis is not specific to any one class; it hits any class that has both a static `valueOf` and gets a typed null taken from it. In practice `java.lang.String.valueOf(...)` is broken from app startup in most apps, because passing `java.lang.String.null` is the idiomatic way to disambiguate a null argument.\n\n### Reproduction\n\nAny app, evaluated in the runtime (here via the inspector):\n\n```js\nString(java.lang.Double.valueOf(1)) // \"1.0\" \u003c- correct\ntypeof java.lang.Double.null // \"function\" \u003c- touch the marker once\nString(java.lang.Double.valueOf(1)) // \"null\" \u003c- now permanently broken\njava.lang.Double.toString(1) // \"1.0\" \u003c- other statics unaffected\n```\n\nThe property is visibly deleted and re-added — `valueOf` moves from its metadata slot to the end of the key order:\n\n```js\nObject.getOwnPropertyNames(java.lang.Double).indexOf(\"valueOf\") // 19 (of 35) before\nObject.getOwnPropertyNames(java.lang.Double).indexOf(\"valueOf\") // 34 (of 35) after\n```\n\n`java.lang.String` shows the post-mutation shape from startup in any app that uses `java.lang.String.null`:\n\n```js\nString(java.lang.String.valueOf(7)) // \"null\"\nObject.getOwnPropertyNames(java.lang.String)\n// [... \"copyValueOf\", \"format\", \"join\", \"extend\", \"CASE_INSENSITIVE_ORDER\", \"null\", \"class\", \"valueOf\"]\n// ^ moved to last\n```\n\n### Expected vs actual\n\n- **Expected:** `java.lang.String.valueOf(42)` → `\"42\"`; taking `SomeClass.null` has no effect on that class's static methods.\n- **Actual:** returns `null`, silently, forever after the first read of `.null` on that class.\n\n### Root cause\n\n`test-app/runtime/src/main/cpp/MetadataNode.cpp`, `NullObjectAccessorGetterCallback` (the getter installed for `.null`):\n\n```cpp\nauto thiz = info.This(); // the class constructor function itself\n...\nauto funcTemplate = FunctionTemplate::New(isolate, MetadataNode::NullValueOfCallback);\nthiz->Delete(context, V8StringConstants::GetValueOf(isolate));\nthiz->Set(context, V8StringConstants::GetValueOf(isolate),\n funcTemplate->GetFunction(context).ToLocalChecked());\n...\ninfo.GetReturnValue().Set(thiz); // the marker IS the ctor function\n```\n\nand `NullValueOfCallback` is simply:\n\n```cpp\nargs.GetReturnValue().SetNull();\n```\n\nSo the \"make this object read as null\" shim is installed on the class object rather than on a distinct marker object, and it overwrites a real Java static of the same name. The guard around it (`hiddenVal.IsEmpty()`) only makes it happen once — it does not make it reversible.\n\n### Suggested direction\n\nReturn a dedicated marker object from the `.null` getter instead of the constructor function itself — e.g. an empty object carrying the same `MetadataNodeKeys` internal fields plus the null-node private value, with `valueOf` installed on *that*. The argument-resolution path already identifies typed nulls via the `NULL_NODE_NAME` private value, so it should not need the marker to be the class object.\n\nFailing that, at minimum the shim should not clobber a name that exists in the class's metadata.\n\n### Affected versions\n\n- Reproduced on `@nativescript/android` **9.0.x** (V8 10.3.22), the currently published runtime.\n- Also reproduces unchanged on a local branch running **V8 14.9.207.39**, so it is independent of the V8 version — this is long-standing, not a recent regression.\n\nTested on an API 35 arm64 emulator.\n","author":{"url":"https://github.com/edusperoni","@type":"Person","name":"edusperoni"},"datePublished":"2026-07-26T13:49:14Z","url":"https://github.com/NativeScript/android/issues/1986"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1678b1ad-6d18-1c97-76ad-fb1ed0909ebe |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAA0:19E4BB:1713DB6:1D6DE8A:6B013B9A |
| html-safe-nonce | afc29d3f94b0bb5cd6b952066618a4ede9939a3714413671ec05aa44facbab68 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUEwOjE5RTRCQjoxNzEzREI2OjFENkRFOEE6NkIwMTNCOUEiLCJ2aXNpdG9yX2lkIjoiMjA2ODM2MjA3OTA3MzIyNzc4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 472a6f6ff47ffd0a9d60a375b8302b3b1febeb8bfb2c0876d06d535e64f5556c |
| hovercard-subject-tag | issue:4980846833 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/android/1986/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4d7ea5c66e1bde938253663b75304e59fe32d94b1c5e0d042d06f93620968fac/NativeScript/android/issues/1986 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4d7ea5c66e1bde938253663b75304e59fe32d94b1c5e0d042d06f93620968fac/NativeScript/android/issues/1986 |
| og:image:alt | Summary Reading the typed-null marker SomeJavaClass.null permanently breaks SomeJavaClass.valueOf(...) for the remaining life of the isolate — it silently starts returning null for every argument. ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | edusperoni |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/android git https://github.com/NativeScript/android.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 29137950 |
| octolytics-dimension-repository_nwo | NativeScript/android |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 29137950 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/android |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width