Title: fix: proxy generation races and naming bugs by edusperoni · Pull Request #2117 · NativeScript/android · GitHub
Open Graph Title: fix: proxy generation races and naming bugs by edusperoni · Pull Request #2117 · NativeScript/android
X Title: fix: proxy generation races and naming bugs by edusperoni · Pull Request #2117 · NativeScript/android
Description: Description Fixes the items of #2019 that #2116 does not cover: two races in runtime class generation that any app using workers can hit, and five smaller defects on the same path. Races Shared scratch state in the runtime class generator. Dump kept its method-descriptor buffer and the interface list of an interface implementation in static fields. Every runtime (main and each worker) has its own generator, so two threads generating at once interleaved on them and could write wrong descriptors or the wrong interface into a class, with no error. Both are now per call. A new JVM test generates 13 classes on 8 threads and compares the bytes with sequential output. On the unfixed code it failed in two of two runs: once by hanging, once with a NullPointerException inside the dex writer. After the fix it passes in about a second, 15 of 15 runs. A new spec has three workers and the main runtime generate six classes each at the same moment, then calls every overridden method from Java. ConcurrentModificationException while looking up a class. ClassStorageServiceImpl.retrieveClass iterated the class-loader set without its lock while another runtime could add a loader. The set is now copy-on-write, so iteration works on a snapshot and no lock is held across loadClass. A new unit test threw ConcurrentModificationException before the fix. Smaller defects Jar path. replace(".dex", ".jar") rewrote every occurrence in the path, not the suffix. The path starts with the app's data directory, so an application id with a segment starting with dex (for example com.example.dexter) sent every jar to a directory that does not exist. Failed class lookups were cached as null. After one failed lookup, a class that appeared later (generated or injected) was returned as a new JNI global reference that was never stored or freed, leaking one global reference per lookup. A miss is no longer cached. Prefix check. ClassResolver tested com.tns.gen and DexFactory tested com.tns.gen.; both now use one constant. A name such as com.tns.generated.Foo is looked up as a named class first and then generated as one, which is what DexFactory already did with it. com.tns.tests. exclusion removed. It has been unreachable since the prefix became com.tns.gen in 2015, so this changes no behaviour. Dotted extend() names are validated. Base.extend("a.b.C", ...) and @JavaProxy("a.b.C") skipped validation entirely. A name with an empty part, or with a character a dex class name cannot contain, now throws a JS error that names it. A part that is legal in dex but not a Java identifier (leading digit, -) still works and logs a warning, because the static binding generator can never compile such a class. / is still accepted as a separator, as ClassResolver already reads it as .. The name-validation specs, disabled since the suite started running the static binding generator, are back, with call sites the generator does not parse. Not included The truncated-jar and single-read items and Interface.extend on a nested interface: fixed in #2116. Two runtimes resolving the same unnamed class at once (an interface's shared class, or one call site in code both run) still both generate it and write the same dex and jar. #2116 makes those writes atomic. Only the main runtime injects into the app class loader, and the process-wide class cache keeps whichever class was published first, so what remains is duplicated work. A named proxy colliding with a derived anonymous name still fails with a bare ClassNotFoundException; that path belongs to the explicit-name handling #2116 changes. Verification Full suite on an API 33 arm64 phone: 1611 specs, 0 failures (1600 on main plus 11 new). :runtime:testDebugUnitTest: 32 tests, 0 failures. A trial merge with #2116's branch has no conflicts; the two can merge in either order. Only API 33 was tested locally. Related Pull Requests Addresses the remaining items of #2019. Together with #2116 this covers the whole issue, so it can be closed when both are merged. #2116 Does your pull request have unit tests? Yes: DumpConcurrencyTest and a concurrency case in ClassLoadersCollectionImplTest (JVM), plus test-app specs for dotted extend names and for concurrent generation across the main runtime and workers. Summary by CodeRabbit Bug Fixes Improved reliability when Java proxies are generated concurrently. Class-loading and proxy generation now handle missing classes and class names more consistently. Dotted class names with invalid characters or empty parts are rejected; some names unsupported by static generation remain available at runtime. Tests Added coverage for concurrent proxy generation, class loading, and stable proxy output.
Open Graph Description: Description Fixes the items of #2019 that #2116 does not cover: two races in runtime class generation that any app using workers can hit, and five smaller defects on the same path. Races Shared sc...
X Description: Description Fixes the items of #2019 that #2116 does not cover: two races in runtime class generation that any app using workers can hit, and five smaller defects on the same path. Races Shared sc...
Opengraph URL: https://github.com/NativeScript/android/pull/2117
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:9faa5cc5-db23-f686-e77c-604cdac1567b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8762:311640:1624CF0:1C2A5CA:6B0135A2 |
| html-safe-nonce | 6a709e1b59437d056098ef6a92d7c8130c3c1ac6ce22cf94397ce48c82f22610 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzYyOjMxMTY0MDoxNjI0Q0YwOjFDMkE1Q0E6NkIwMTM1QTIiLCJ2aXNpdG9yX2lkIjoiMzYzMDkyNjE0OTM3MjE2MzQ5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0f421de79d285398bb329c28c23b50e4bcaed459144982eab73c40c8647fa291 |
| hovercard-subject-tag | pull_request:5350704091 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/NativeScript/android/pull/2117/files |
| twitter:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4061767?s=400&v=4 |
| og:image:alt | Description Fixes the items of #2019 that #2116 does not cover: two races in runtime class generation that any app using workers can hit, and five smaller defects on the same path. Races Shared sc... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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 |
Links:
Viewport: width=device-width