bind: correctly generate methods with implicit this and parameters
Change-Id: I885a21876d9f639bc0996c9279fd0afefa93cef6
Reviewed-on: https://go-review.googlesource.com/29877
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/bind/genjava.go b/bind/genjava.go
index c0b1569..589af2f 100644
--- a/bind/genjava.go
+++ b/bind/genjava.go
@@ -298,13 +298,13 @@
func (g *JavaGen) genFuncArgs(f *types.Func, jm *java.Func) {
sig := f.Type().(*types.Signature)
params := sig.Params()
- i := 0
+ first := 0
if jm != nil {
// Skip the implicit this argument to the Go method
- i = params.Len() - len(jm.Params)
+ first = params.Len() - len(jm.Params)
}
- for ; i < params.Len(); i++ {
- if i > 0 {
+ for i := first; i < params.Len(); i++ {
+ if i > first {
g.Printf(", ")
}
v := params.At(i)
diff --git a/bind/testpkg/javapkg/classes.go b/bind/testpkg/javapkg/classes.go
index da18266..9915391 100644
--- a/bind/testpkg/javapkg/classes.go
+++ b/bind/testpkg/javapkg/classes.go
@@ -149,3 +149,11 @@
type NoargConstructor struct {
util.BitSet // An otherwise unused class with a no-arg constructor
}
+
+type GoRand struct {
+ util.Random
+}
+
+func (_ *GoRand) Next(this util.Random, i int32) int32 {
+ return this.Super().Next(i)
+}