dart-lang / native

Dart packages related to FFI and native assets bundling.
BSD 3-Clause "New" or "Revised" License
153 stars 43 forks source link

Java inheritance is missing #1653

Open stuartmorgan opened 1 week ago

stuartmorgan commented 1 week ago

I'm running jnigen on public interface ExoPlayer extends Player {...} The resulting Dart object is class ExoPlayer extends _$jni.JObject {...}, with none of the methods from Player.

I thought the problem was that I wasn't generating Player, so I added that to my config (although I would have filed that as an issue if that were it; this should Just Work IMO), but it didn't help; I have the Player class now too, but ExoPlayer is still just class ExoPlayer extends _$jni.JObject and didn't get any new methods.

HosseinYousefi commented 1 week ago

Will be solved by: https://github.com/dart-lang/native/issues/577. I will prioritize this.

but ExoPlayer is still just class ExoPlayer extends _$jni.JObject and didn't get any new methods.

This technically shouldn't be, will investigate.

stuartmorgan commented 1 week ago

This technically shouldn't be, will investigate.

Yes, I saw class inheritance in your prototype, so I was confused by it not being in mine. I wasn't sure if I was doing something non-obviously wrong, or it was something that was implemented on a branch.

stuartmorgan commented 1 week ago

FYI I'm not blocked on this; I just made a helper to Java-cast to the superclass. This is definitely an important use case to have working, but no need to change any short-term work planning on my account.

HosseinYousefi commented 1 week ago

Yes, I saw class inheritance in your prototype, so I was confused by it not being in mine. I wasn't sure if I was doing something non-obviously wrong, or it was something that was implemented on a branch.

I think I know why this happened. Probably extends for interfaces is equivalent to implements and we only use extends for inheritance.

HosseinYousefi commented 1 week ago

I just made a helper to Java-cast to the superclass.

Possible to do exoPlayer.as(Player.type) in Dart to cast as well.

stuartmorgan commented 1 week ago

Yes, that's what I meant by Java-cast, sorry for the confusing terminology. The helper I was referring to is a Dart helper because I need to do this constantly in the code, because most of the methods are on the superclass.