ffi #jni_main: drop implicit super call from @Override delegate
The Java @Override no longer injects a `super.<method>(...)` call before
the native delegate. The user calls super from the sx-side body when
needed — via a forthcoming `super.method(args)` dispatch lowered to
`CallNonvirtual<Type>Method` on JNI classes.
Two reasons:
- Interface method impls (e.g. SurfaceHolder.Callback) have no super
to call. The previous emit produced javac-rejected code for those.
- Lifecycle overrides may want to skip super in some cases, or call
it with different args. The emitter can't second-guess intent.
User-space control of the dispatch keeps the emitter free of "is this
an interface method or a supertype override?" guesswork. The dex
shrinks by one virtual-method bytecode invocation per override.
Caveat: until the sx-side `super.method(args)` dispatch lands, Activity
lifecycle methods (onCreate, onResume, etc.) that mandate `super.<>`
will throw `SuperNotCalledException` at runtime if their bodies don't
do their own JNI dispatch. The slice 2 smoke still launches cleanly
because its onCreate body is empty.
131 host / 4 cross / zig build test all green.
This commit is contained in:
@@ -88,7 +88,6 @@ test "void onCreate(Bundle) with default Activity superclass" {
|
||||
\\public class SxNativeActivity extends android.app.Activity {
|
||||
\\ @Override
|
||||
\\ public void onCreate(android.os.Bundle b) {
|
||||
\\ super.onCreate(b);
|
||||
\\ sx_onCreate(b);
|
||||
\\ }
|
||||
\\ private native void sx_onCreate(android.os.Bundle b);
|
||||
@@ -126,7 +125,7 @@ test "primitive params" {
|
||||
defer a.free(out);
|
||||
|
||||
try std.testing.expect(std.mem.indexOf(u8, out, "public void onWindowFocusChanged(boolean hasFocus)") != null);
|
||||
try std.testing.expect(std.mem.indexOf(u8, out, "super.onWindowFocusChanged(hasFocus);") != null);
|
||||
try std.testing.expect(std.mem.indexOf(u8, out, "super.onWindowFocusChanged") == null); // emitter never injects super
|
||||
try std.testing.expect(std.mem.indexOf(u8, out, "sx_onWindowFocusChanged(hasFocus);") != null);
|
||||
try std.testing.expect(std.mem.indexOf(u8, out, "private native void sx_onWindowFocusChanged(boolean hasFocus);") != null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user