x/mobile: passing `error` into a callback crashes the library init #17073
Labels
Milestone
Comments
Thank you. Is the type declaration enough to crash the program? If not, please provide the complete code and I'll take a look. |
It is enough. I've added the following code to the end of type ErrorCrasher interface {
OnError(err error)
} And ran the
|
CL https://golang.org/cl/29176 mentions this issue. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When a method returns an error type, gomobile will internally convert that into a Java exception Android side. Of course, converting errors into exceptions would mean that an
error
cannot be passed to a callback method (implemented in Java) since it's not actually a real type, rather a special case.However doing exactly this will cause gomobile to happily build the archive without reporting an error. This will result in the library crashing the android application when it's first accessed. Since errors are handled in a special way I can fully accept that they cannot be passed to functions as an argument, however we should probably abort compilation in that case and bail out with an error.
e.g. the below interface will build and crash upon library load
The error is something like this:
The text was updated successfully, but these errors were encountered: