Visitar URL original
[android] ES class extends of a Java class produces an unproxied superclass under @nativescript/vite dev · Issue #11503 · NativeScript/NativeScript · GitHub
Skip to content

[android] ES class extends of a Java class produces an unproxied superclass under @nativescript/vite dev #11503

Description

@aleclarson

Environment

  • @nativescript/core 9.1.2
  • @nativescript/android 9.1.1
  • @nativescript/vite 8.0.17
  • Android 15 emulator (API 35)

Repro

class ReproView extends android.view.View {
	override onDraw(canvas: android.graphics.Canvas): void {
		console.log('onDraw')
	}
}

const v = new ReproView(Utils.android.getApplicationContext())
console.log(v.getClass().getName())

const content = Application.android.foregroundActivity.findViewById(android.R.id.content)
content.addView(v, new android.view.ViewGroup.LayoutParams(60, 60))

Expected

getClass().getName() returns a generated proxy subclass (e.g. com.tns.gen.android.view.View_...), and onDraw dispatches into the JS override — the same outcome as (android.view.View as any).extend({ onDraw ... }), which produces a View_ts_* class and works correctly on the same stack.

Actual

getClass().getName() returns android.view.View — a plain superclass instance with no generated subclass. All JS overrides (onDraw, onMeasure, draw, onAttachedToWindow) are silently dead: the view mounts, lays out, and never calls them.

Notes

  • The failure is silent — nothing in logcat indicates proxy generation was skipped. We only found it because a custom-draw view (an SVG renderer) mounted with correct bounds but painted nothing.
  • __extends-compiled classes DO generate proxies at runtime on this stack (logcat shows Class X not precompiled; generating at runtime for framework classes and they dispatch correctly). It looks like the vite dev module path serves real ES class syntax that bypasses whichever mechanism intercepts Java-class extension — either the __extends hook or V8-level extends interception.
  • Verified via run-as file probes from inside the app: onDraw never ran, while getClass().getName() reported the superclass. After switching the same view to View.extend({...}), getClass().getName() reported a generated View_ts_* subclass and onDraw fired.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions