Fix initialization of deep derived types #353

Merged
jwharm merged 2 commits from derived-types into main 2026-04-20 20:01:40 +02:00
Owner

When a new GTypeInstance is initialized, the instance_init_func of every class in the parent hierarchy is called, and each time the typeclass pointer is set to that type's typeclass. However, this confused java-gi because it created a Java object of the parent type, instead of the derived class.

This is now fixed by using the gClass parameter of the instance_init_func, because that parameter actually contains the typeclass we need to create a Java object for.

Fixes #351

When a new GTypeInstance is initialized, the `instance_init_func` of every class in the parent hierarchy is called, and each time the typeclass pointer is set to that type's typeclass. However, this confused java-gi because it created a Java object of the parent type, instead of the derived class. This is now fixed by using the `gClass` parameter of the `instance_init_func`, because that parameter actually contains the typeclass we need to create a Java object for. Fixes #351
When a new GTypeInstance is initialized, the `instance_init_func`
of every class in the parent hierarchy is called, and each time the
typeclass pointer is set to that type's typeclass. However, this
confused java-gi because it created a Java object of the parent
type, instead of the derived class.

This is now fixed by using the `gClass` parameter of the
`instance_init_func`, because that parameter actually contains the
typeclass we need to create a Java object for.

Fixes #351
jwharm merged commit 631588e5a5 into main 2026-04-20 20:01:40 +02:00
Sign in to join this conversation.
No description provided.