Closed oxisto closed 2 years ago
I suspect, that this line here: https://github.com/timob/jnigi/blob/1481db6c0949c942d83600a594c1664f92b337b1/jnigi.go#L1119
should probably refer o.GetClassName()
rather than o.className
so the casted object ref can set the class.
Yes that's a problem.
We can't just change o.className
to o.GetClassName()
on the above line because it will refer to the method defined on *ObjectRef
.
I think the way to fix this is to just have:
func (o *ObjectRef) Cast(className string) *ObjectRef {
return &ObjectRef{o.jobject, className, o.isArray}
}
And remove CastedObjectRef
type all together.
Yes that's a problem.
We can't just change
o.className
too.GetClassName()
on the above line because it will refer to the method defined on*ObjectRef
.I think the way to fix this is to just have:
func (o *ObjectRef) Cast(className string) *ObjectRef { return &ObjectRef{o.jobject, className, o.isArray} }
And remove
CastedObjectRef
type all together.
Sounds like a good solution.
I have a simple class hierarchy in my project, e.g.,
ObjectType
which derives fromType
.ObjectType
has a functionaddGeneric
which takes aType
as parameter and returns void.I am trying to cast-call this method on an object ref, but it seems that the base class is chosen for the method call, rather than the casted class: