Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/bind: function with argument of type declared in same package skipped after binding #37155

Open
rossus opened this issue Feb 10, 2020 · 6 comments
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rossus
Copy link

rossus commented Feb 10, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.7 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/snap/go/current"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/snap/go/current/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build676544878=/tmp/go-build -gno-record-gcc-switches"

What did you do?

type Item struct {
    Label string
}

func UseItem(item Item) {}
$ gomobile bind -o Item.aar -v -target=android github.com/my/repo/mobile/pkg

What did you expect to see?

function UseItem() is working normally after bind

What did you see instead?

After unzipping the .jar file I can see inside it file with:

// skipped function UseItem with unsupported parameter or return types
@gopherbot gopherbot added this to the Unreleased milestone Feb 10, 2020
@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Feb 10, 2020
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 14, 2020
@dmitshur
Copy link
Contributor

/cc @hyangah @hajimehoshi

@hajimehoshi
Copy link
Member

hajimehoshi commented Feb 15, 2020

Does this work if *Item is used instead of Item?

@hajimehoshi
Copy link
Member

https://godoc.org/golang.org/x/mobile/cmd/gobind#hdr-Type_restrictions

  • Any function type all of whose parameters and results have
    supported types. Functions must return either no results,
    one result, or two results where the type of the second is
    the built-in 'error' type.
  • Any struct type, all of whose exported methods have
    supported function types and all of whose exported fields
    have supported types.

Hm, this sounds a bug if the function with Item is not exposed.

CC @eliasnaur

@rossus
Copy link
Author

rossus commented Mar 11, 2020

Yes, it works with *Item.

@hajimehoshi
Copy link
Member

In my intuition, copying a struct, not a pointer, should not work well between Java and other languages (Go in this case). Is that correct? Then we should update the document to make this rule explicit. @hyangah, @eliasnaur, what do you think?

@nrobi144
Copy link

nrobi144 commented Sep 7, 2022

Bumped into this today. Using pointer works. https://github.com/TBD54566975/ssi-sdk/pull/184/files#r964681497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants