bind: include all generated code in tests
The tests was missing the generated code for the universe package
and some parts of the reverse generated code. Include it.
Change-Id: Id5e2f215c8f6f717c30377965255c4b64f31e923
Reviewed-on: https://go-review.googlesource.com/34992
Reviewed-by: David Crawshaw <crawshaw@golang.org>
diff --git a/bind/bind_test.go b/bind/bind_test.go
index 5864319..b9fe99a 100644
--- a/bind/bind_test.go
+++ b/bind/bind_test.go
@@ -31,6 +31,7 @@
var updateFlag = flag.Bool("update", false, "Update the golden files.")
var tests = []string{
+ "", // The universe package with the error type.
"testdata/basictypes.go",
"testdata/structs.go",
"testdata/interfaces.go",
@@ -126,17 +127,22 @@
func TestGenObjc(t *testing.T) {
for _, filename := range tests {
- pkg := typeCheck(t, filename, "")
+ var pkg *types.Package
+ if filename != "" {
+ pkg = typeCheck(t, filename, "")
+ }
var buf bytes.Buffer
g := &ObjcGen{
Generator: &Generator{
Printer: &Printer{Buf: &buf, IndentEach: []byte("\t")},
Fset: fset,
- AllPkg: []*types.Package{pkg},
Pkg: pkg,
},
}
+ if pkg != nil {
+ g.AllPkg = []*types.Package{pkg}
+ }
g.Init(nil)
testcases := []struct {
@@ -164,7 +170,13 @@
}
out := writeTempFile(t, "generated"+tc.suffix, buf.Bytes())
defer os.Remove(out)
- golden := filename[:len(filename)-len(".go")] + tc.suffix
+ var golden string
+ if filename != "" {
+ golden = filename[:len(filename)-len(".go")]
+ } else {
+ golden = "testdata/universe"
+ }
+ golden += tc.suffix
if diffstr := diff(golden, out); diffstr != "" {
t.Errorf("%s: does not match Objective-C golden:\n%s", filename, diffstr)
if *updateFlag {
@@ -216,6 +228,8 @@
}
func genJavaPackages(t *testing.T, dir string, cg *ClassGen) {
+ buf := cg.Buf
+ cg.Buf = new(bytes.Buffer)
pkgBase := filepath.Join(dir, "src", "Java")
if err := os.MkdirAll(pkgBase, 0700); err != nil {
t.Fatal(err)
@@ -231,6 +245,7 @@
if err := ioutil.WriteFile(pkgFile, cg.Buf.Bytes(), 0600); err != nil {
t.Fatal(err)
}
+ io.Copy(buf, cg.Buf)
}
cg.Buf.Reset()
cg.GenInterfaces()
@@ -238,6 +253,8 @@
if err := ioutil.WriteFile(clsFile, cg.Buf.Bytes(), 0600); err != nil {
t.Fatal(err)
}
+ io.Copy(buf, cg.Buf)
+ cg.Buf = buf
cmd := exec.Command(
"go",
@@ -257,44 +274,51 @@
allTests = append(append([]string{}, allTests...), javaTests...)
}
for _, filename := range allTests {
- refs := fileRefs(t, filename, "Java/")
- imp := &java.Importer{}
- classes, err := imp.Import(refs)
- if err != nil {
- t.Fatal(err)
- }
- var cg *ClassGen
- tmpGopath := ""
+ var pkg *types.Package
var buf bytes.Buffer
- if len(classes) > 0 {
- tmpGopath, err = ioutil.TempDir(os.TempDir(), "gomobile-bind-test-")
+ var cg *ClassGen
+ var classes []*java.Class
+ if filename != "" {
+ refs := fileRefs(t, filename, "Java/")
+ imp := &java.Importer{}
+ var err error
+ classes, err = imp.Import(refs)
if err != nil {
t.Fatal(err)
}
- defer os.RemoveAll(tmpGopath)
- cg = &ClassGen{
- Printer: &Printer{
- IndentEach: []byte("\t"),
- Buf: new(bytes.Buffer),
- },
+ tmpGopath := ""
+ if len(classes) > 0 {
+ tmpGopath, err = ioutil.TempDir(os.TempDir(), "gomobile-bind-test-")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer os.RemoveAll(tmpGopath)
+ cg = &ClassGen{
+ Printer: &Printer{
+ IndentEach: []byte("\t"),
+ Buf: new(bytes.Buffer),
+ },
+ }
+ var genNames []string
+ for _, emb := range refs.Embedders {
+ genNames = append(genNames, emb.Pkg+"."+emb.Name)
+ }
+ cg.Init(classes, genNames)
+ genJavaPackages(t, tmpGopath, cg)
+ cg.Buf = &buf
}
- var genNames []string
- for _, emb := range refs.Embedders {
- genNames = append(genNames, emb.Pkg+"."+emb.Name)
- }
- cg.Init(classes, genNames)
- genJavaPackages(t, tmpGopath, cg)
- cg.Buf = &buf
+ pkg = typeCheck(t, filename, tmpGopath)
}
- pkg := typeCheck(t, filename, tmpGopath)
g := &JavaGen{
Generator: &Generator{
Printer: &Printer{Buf: &buf, IndentEach: []byte(" ")},
Fset: fset,
- AllPkg: []*types.Package{pkg},
Pkg: pkg,
},
}
+ if pkg != nil {
+ g.AllPkg = []*types.Package{pkg}
+ }
g.Init(classes)
testCases := []struct {
suffix string
@@ -339,7 +363,13 @@
}
out := writeTempFile(t, "generated"+tc.suffix, buf.Bytes())
defer os.Remove(out)
- golden := filename[:len(filename)-len(".go")] + tc.suffix
+ var golden string
+ if filename != "" {
+ golden = filename[:len(filename)-len(".go")]
+ } else {
+ golden = "testdata/universe"
+ }
+ golden += tc.suffix
if diffstr := diff(golden, out); diffstr != "" {
t.Errorf("%s: does not match Java golden:\n%s", filename, diffstr)
@@ -358,7 +388,10 @@
func TestGenGo(t *testing.T) {
for _, filename := range tests {
var buf bytes.Buffer
- pkg := typeCheck(t, filename, "")
+ var pkg *types.Package
+ if filename != "" {
+ pkg = typeCheck(t, filename, "")
+ }
testGenGo(t, filename, &buf, pkg)
}
}
@@ -437,7 +470,9 @@
Writer: buf,
Fset: fset,
Pkg: pkg,
- AllPkg: []*types.Package{pkg},
+ }
+ if pkg != nil {
+ conf.AllPkg = []*types.Package{pkg}
}
if err := GenGo(conf); err != nil {
t.Errorf("%s: %v", filename, err)
@@ -445,7 +480,11 @@
}
out := writeTempFile(t, "go", buf.Bytes())
defer os.Remove(out)
- golden := filename + ".golden"
+ golden := filename
+ if golden == "" {
+ golden = "testdata/universe"
+ }
+ golden += ".golden"
if diffstr := diff(golden, out); diffstr != "" {
t.Errorf("%s: does not match Go golden:\n%s", filename, diffstr)
diff --git a/bind/testdata/classes.go.golden b/bind/testdata/classes.go.golden
index 7cff13e..ee32517 100644
--- a/bind/testdata/classes.go.golden
+++ b/bind/testdata/classes.go.golden
@@ -1,5 +1,329 @@
// File is generated by gobind. Do not edit.
+package Runnable
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Runnable proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Runnable.
+ Cast func(v interface{}) Java.Java_lang_Runnable
+)
+
+// File is generated by gobind. Do not edit.
+
+package lang
+
+import "Java"
+
+const _ = Java.Dummy
+
+type Runnable Java.Java_lang_Runnable
+type Object Java.Java_lang_Object
+type System Java.Java_lang_System
+// File is generated by gobind. Do not edit.
+
+package InputStream
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.io.InputStream proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.io.InputStream.
+ Cast func(v interface{}) Java.Java_io_InputStream
+)
+
+// File is generated by gobind. Do not edit.
+
+package io
+
+import "Java"
+
+const _ = Java.Dummy
+
+type InputStream Java.Java_io_InputStream
+type Console Java.Java_io_Console
+// File is generated by gobind. Do not edit.
+
+package Future
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.util.concurrent.Future proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.util.concurrent.Future.
+ Cast func(v interface{}) Java.Java_util_concurrent_Future
+)
+
+// File is generated by gobind. Do not edit.
+
+package concurrent
+
+import "Java"
+
+const _ = Java.Dummy
+
+type Future Java.Java_util_concurrent_Future
+type TimeUnit Java.Java_util_concurrent_TimeUnit
+// File is generated by gobind. Do not edit.
+
+package Object
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Object proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Object.
+ Cast func(v interface{}) Java.Java_lang_Object
+)
+
+// File is generated by gobind. Do not edit.
+
+package TimeUnit
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.util.concurrent.TimeUnit proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.util.concurrent.TimeUnit.
+ Cast func(v interface{}) Java.Java_util_concurrent_TimeUnit
+)
+
+// File is generated by gobind. Do not edit.
+
+package Spliterators
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ Iterator_Ljava_util_Spliterator_00024OfInt_2 func(a0 Java.Java_util_Spliterator_OfInt) Java.Java_util_PrimitiveIterator_OfInt
+ // Cast takes a proxy for a Java object and converts it to a java.util.Spliterators proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.util.Spliterators.
+ Cast func(v interface{}) Java.Java_util_Spliterators
+)
+
+// File is generated by gobind. Do not edit.
+
+package util
+
+import "Java"
+
+const _ = Java.Dummy
+
+type Spliterators Java.Java_util_Spliterators
+// File is generated by gobind. Do not edit.
+
+package System
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ Console func() Java.Java_io_Console
+ // Cast takes a proxy for a Java object and converts it to a java.lang.System proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.System.
+ Cast func(v interface{}) Java.Java_lang_System
+)
+
+// File is generated by gobind. Do not edit.
+
+package Future
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.Future proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.Future.
+ Cast func(v interface{}) Java.Java_Future
+)
+
+// File is generated by gobind. Do not edit.
+
+package java
+
+import "Java"
+
+const _ = Java.Dummy
+
+type Future Java.Java_Future
+type InputStream Java.Java_InputStream
+type Object Java.Java_Object
+type Runnable Java.Java_Runnable
+// File is generated by gobind. Do not edit.
+
+package InputStream
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.InputStream proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.InputStream.
+ Cast func(v interface{}) Java.Java_InputStream
+)
+
+// File is generated by gobind. Do not edit.
+
+package Object
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.Object proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.Object.
+ Cast func(v interface{}) Java.Java_Object
+)
+
+// File is generated by gobind. Do not edit.
+
+package Runnable
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.Runnable proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.Runnable.
+ Cast func(v interface{}) Java.Java_Runnable
+)
+
+// File is generated by gobind. Do not edit.
+
+package OfInt
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.util.PrimitiveIterator.OfInt proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.util.PrimitiveIterator.OfInt.
+ Cast func(v interface{}) Java.Java_util_PrimitiveIterator_OfInt
+)
+
+// File is generated by gobind. Do not edit.
+
+package PrimitiveIterator
+
+import "Java"
+
+const _ = Java.Dummy
+
+type OfInt Java.Java_util_PrimitiveIterator_OfInt
+// File is generated by gobind. Do not edit.
+
+package OfInt
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.util.Spliterator.OfInt proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.util.Spliterator.OfInt.
+ Cast func(v interface{}) Java.Java_util_Spliterator_OfInt
+)
+
+// File is generated by gobind. Do not edit.
+
+package Spliterator
+
+import "Java"
+
+const _ = Java.Dummy
+
+type OfInt Java.Java_util_Spliterator_OfInt
+// File is generated by gobind. Do not edit.
+
+package Console
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.io.Console proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.io.Console.
+ Cast func(v interface{}) Java.Java_io_Console
+)
+
+// File is generated by gobind. Do not edit.
+
package Java
// Used to silence this package not used errors
diff --git a/bind/testdata/java.go.golden b/bind/testdata/java.go.golden
index d40fa3f..f512c21 100644
--- a/bind/testdata/java.go.golden
+++ b/bind/testdata/java.go.golden
@@ -1,5 +1,172 @@
// File is generated by gobind. Do not edit.
+package Float
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+ MAX_VALUE = 3.4028235E38
+ MIN_NORMAL = 1.17549435E-38
+ MIN_VALUE = 1.4E-45
+ MAX_EXPONENT = 127
+ MIN_EXPONENT = -126
+ SIZE = 32
+ BYTES = 4
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Float proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Float.
+ Cast func(v interface{}) Java.Java_lang_Float
+)
+
+// File is generated by gobind. Do not edit.
+
+package lang
+
+import "Java"
+
+const _ = Java.Dummy
+
+type Float Java.Java_lang_Float
+type Object Java.Java_lang_Object
+type Runnable Java.Java_lang_Runnable
+type Character Java.Java_lang_Character
+// File is generated by gobind. Do not edit.
+
+package Object
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Object proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Object.
+ Cast func(v interface{}) Java.Java_lang_Object
+)
+
+// File is generated by gobind. Do not edit.
+
+package Runnable
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Runnable proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Runnable.
+ Cast func(v interface{}) Java.Java_lang_Runnable
+)
+
+// File is generated by gobind. Do not edit.
+
+package Character
+
+import "Java"
+
+const _ = Java.Dummy
+
+type Subset Java.Java_lang_Character_Subset
+const (
+ MIN_RADIX = 2
+ MAX_RADIX = 36
+ UNASSIGNED = 0
+ UPPERCASE_LETTER = 1
+ LOWERCASE_LETTER = 2
+ TITLECASE_LETTER = 3
+ MODIFIER_LETTER = 4
+ OTHER_LETTER = 5
+ NON_SPACING_MARK = 6
+ ENCLOSING_MARK = 7
+ COMBINING_SPACING_MARK = 8
+ DECIMAL_DIGIT_NUMBER = 9
+ LETTER_NUMBER = 10
+ OTHER_NUMBER = 11
+ SPACE_SEPARATOR = 12
+ LINE_SEPARATOR = 13
+ PARAGRAPH_SEPARATOR = 14
+ CONTROL = 15
+ FORMAT = 16
+ PRIVATE_USE = 18
+ SURROGATE = 19
+ DASH_PUNCTUATION = 20
+ START_PUNCTUATION = 21
+ END_PUNCTUATION = 22
+ CONNECTOR_PUNCTUATION = 23
+ OTHER_PUNCTUATION = 24
+ MATH_SYMBOL = 25
+ CURRENCY_SYMBOL = 26
+ MODIFIER_SYMBOL = 27
+ OTHER_SYMBOL = 28
+ INITIAL_QUOTE_PUNCTUATION = 29
+ FINAL_QUOTE_PUNCTUATION = 30
+ DIRECTIONALITY_UNDEFINED = -1
+ DIRECTIONALITY_LEFT_TO_RIGHT = 0
+ DIRECTIONALITY_RIGHT_TO_LEFT = 1
+ DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC = 2
+ DIRECTIONALITY_EUROPEAN_NUMBER = 3
+ DIRECTIONALITY_EUROPEAN_NUMBER_SEPARATOR = 4
+ DIRECTIONALITY_EUROPEAN_NUMBER_TERMINATOR = 5
+ DIRECTIONALITY_ARABIC_NUMBER = 6
+ DIRECTIONALITY_COMMON_NUMBER_SEPARATOR = 7
+ DIRECTIONALITY_NONSPACING_MARK = 8
+ DIRECTIONALITY_BOUNDARY_NEUTRAL = 9
+ DIRECTIONALITY_PARAGRAPH_SEPARATOR = 10
+ DIRECTIONALITY_SEGMENT_SEPARATOR = 11
+ DIRECTIONALITY_WHITESPACE = 12
+ DIRECTIONALITY_OTHER_NEUTRALS = 13
+ DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING = 14
+ DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE = 15
+ DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING = 16
+ DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE = 17
+ DIRECTIONALITY_POP_DIRECTIONAL_FORMAT = 18
+ MIN_SUPPLEMENTARY_CODE_POINT = 65536
+ MIN_CODE_POINT = 0
+ MAX_CODE_POINT = 1114111
+ SIZE = 16
+ BYTES = 2
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Character proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Character.
+ Cast func(v interface{}) Java.Java_lang_Character
+)
+
+// File is generated by gobind. Do not edit.
+
+package Subset
+
+import "Java"
+
+const _ = Java.Dummy
+
+const (
+)
+
+var (
+ // Cast takes a proxy for a Java object and converts it to a java.lang.Character.Subset proxy.
+ // Cast panics if the argument is not a proxy or if the underlying object does
+ // not extend or implement java.lang.Character.Subset.
+ Cast func(v interface{}) Java.Java_lang_Character_Subset
+)
+
+// File is generated by gobind. Do not edit.
+
package Java
// Used to silence this package not used errors
diff --git a/bind/testdata/universe.golden b/bind/testdata/universe.golden
new file mode 100644
index 0000000..5c172ff
--- /dev/null
+++ b/bind/testdata/universe.golden
@@ -0,0 +1,40 @@
+// Package gomobile_bind is an autogenerated binder stub for package universe.
+// gobind -lang=go
+//
+// File is generated by gobind. Do not edit.
+package gomobile_bind
+
+/*
+#include <stdlib.h>
+#include <stdint.h>
+#include "seq.h"
+#include "universe.h"
+
+*/
+import "C"
+
+import (
+ _seq "golang.org/x/mobile/bind/seq"
+)
+
+// suppress the error if seq ends up unused
+var _ = _seq.FromRefNum
+
+//export proxy_error_Error
+func proxy_error_Error(refnum C.int32_t) C.nstring {
+ ref := _seq.FromRefNum(int32(refnum))
+ v := ref.Get().(error)
+ res_0 := v.Error()
+ _res_0 := encodeString(res_0)
+ return _res_0
+}
+
+type proxy_error _seq.Ref
+
+func (p *proxy_error) Bind_proxy_refnum__() int32 { return (*_seq.Ref)(p).Bind_IncNum() }
+
+func (p *proxy_error) Error() string {
+ res := C.cproxy_error_Error(C.int32_t(p.Bind_proxy_refnum__()))
+ _res := decodeString(res)
+ return _res
+}
diff --git a/bind/testdata/universe.java.c.golden b/bind/testdata/universe.java.c.golden
new file mode 100644
index 0000000..29ce3cd
--- /dev/null
+++ b/bind/testdata/universe.java.c.golden
@@ -0,0 +1,42 @@
+// JNI functions for the Go <=> Java bridge.
+// gobind -lang=java
+//
+// File is generated by gobind. Do not edit.
+
+#include <android/log.h>
+#include <stdint.h>
+#include "seq.h"
+#include "_cgo_export.h"
+#include "universe.h"
+
+jclass proxy_class__error;
+jmethodID proxy_class__error_cons;
+static jmethodID mid_error_Error;
+
+JNIEXPORT void JNICALL
+Java_go_Universe__1init(JNIEnv *env, jclass _unused) {
+ jclass clazz;
+ clazz = (*env)->FindClass(env, "go/Universe$proxyerror");
+ proxy_class__error = (*env)->NewGlobalRef(env, clazz);
+ proxy_class__error_cons = (*env)->GetMethodID(env, clazz, "<init>", "(Lgo/Seq$Ref;)V");
+ clazz = (*env)->FindClass(env, "java/lang/Throwable");
+ mid_error_Error = (*env)->GetMethodID(env, clazz, "getMessage", "()Ljava/lang/String;");
+}
+
+JNIEXPORT jstring JNICALL
+Java_go_Universe_00024proxyerror_error(JNIEnv* env, jobject __this__) {
+ int32_t o = go_seq_to_refnum_go(env, __this__);
+ nstring r0 = proxy_error_Error(o);
+ jstring _r0 = go_seq_to_java_string(env, r0);
+ return _r0;
+}
+
+nstring cproxy_error_Error(int32_t refnum) {
+ JNIEnv *env = go_seq_push_local_frame(0);
+ jobject o = go_seq_from_refnum(env, refnum, proxy_class__error, proxy_class__error_cons);
+ jstring res = (*env)->CallObjectMethod(env, o, mid_error_Error);
+ nstring _res = go_seq_from_java_string(env, res);
+ go_seq_pop_local_frame(env);
+ return _res;
+}
+
diff --git a/bind/testdata/universe.java.golden b/bind/testdata/universe.java.golden
new file mode 100644
index 0000000..f01d6b2
--- /dev/null
+++ b/bind/testdata/universe.java.golden
@@ -0,0 +1,52 @@
+// Java class go.error is a proxy for talking to a Go program.
+// gobind -lang=java
+//
+// File is generated by gobind. Do not edit.
+package go;
+
+import go.Seq;
+
+public interface error {
+ public String error();
+
+}
+
+// Java class go.Universe is a proxy for talking to a Go program.
+// gobind -lang=java
+//
+// File is generated by gobind. Do not edit.
+package go;
+
+import go.Seq;
+
+public abstract class Universe {
+ static {
+ Seq.touch(); // for loading the native library
+ _init();
+ }
+
+ private Universe() {} // uninstantiable
+
+ // touch is called from other bound packages to initialize this package
+ public static void touch() {}
+
+ private static native void _init();
+
+ private static final class proxyerror extends Exception implements Seq.Proxy, error {
+ private final Seq.Ref ref;
+
+ @Override public final int incRefnum() {
+ int refnum = ref.refnum;
+ Seq.incGoRef(refnum);
+ return refnum;
+ }
+
+ proxyerror(Seq.Ref ref) { this.ref = ref; }
+
+ @Override public String getMessage() { return error(); }
+
+ public native String error();
+ }
+
+
+}
diff --git a/bind/testdata/universe.java.h.golden b/bind/testdata/universe.java.h.golden
new file mode 100644
index 0000000..89118c3
--- /dev/null
+++ b/bind/testdata/universe.java.h.golden
@@ -0,0 +1,16 @@
+// JNI function headers for the Go <=> Java bridge.
+// gobind -lang=java
+//
+// File is generated by gobind. Do not edit.
+
+#ifndef __Universe_H__
+#define __Universe_H__
+
+#include <jni.h>
+
+extern jclass proxy_class__error;
+extern jmethodID proxy_class__error_cons;
+
+nstring cproxy_error_Error(int32_t refnum);
+
+#endif
diff --git a/bind/testdata/universe.objc.go.h.golden b/bind/testdata/universe.objc.go.h.golden
new file mode 100644
index 0000000..50c5c44
--- /dev/null
+++ b/bind/testdata/universe.objc.go.h.golden
@@ -0,0 +1,13 @@
+// Objective-C API for talking to Go package.
+// gobind -lang=objc
+//
+// File is generated by gobind. Do not edit.
+
+#ifndef ___H__
+#define ___H__
+
+#include <stdint.h>
+#include <objc/objc.h>
+nstring cproxy_error_Error(int32_t refnum);
+
+#endif
diff --git a/bind/testdata/universe.objc.h.golden b/bind/testdata/universe.objc.h.golden
new file mode 100644
index 0000000..e47f716
--- /dev/null
+++ b/bind/testdata/universe.objc.h.golden
@@ -0,0 +1,28 @@
+// Objective-C API for talking to Go package.
+// gobind -lang=objc
+//
+// File is generated by gobind. Do not edit.
+
+#ifndef __Universe_H__
+#define __Universe_H__
+
+@import Foundation;
+
+@protocol Universeerror;
+@class Universeerror;
+
+@protocol Universeerror <NSObject>
+- (NSString*)error;
+@end
+
+@class Universeerror;
+
+@interface Universeerror : NSError <goSeqRefInterface, Universeerror> {
+}
+@property(strong, readonly) id _ref;
+
+- (instancetype)initWithRef:(id)ref;
+- (NSString*)error;
+@end
+
+#endif
diff --git a/bind/testdata/universe.objc.m.golden b/bind/testdata/universe.objc.m.golden
new file mode 100644
index 0000000..4e42757
--- /dev/null
+++ b/bind/testdata/universe.objc.m.golden
@@ -0,0 +1,45 @@
+// Objective-C API for talking to Go package.
+// gobind -lang=objc
+//
+// File is generated by gobind. Do not edit.
+
+#include <Foundation/Foundation.h>
+#include "seq.h"
+#include "_cgo_export.h"
+#include "Universe.objc.h"
+
+@implementation Universeerror {
+}
+
+- (instancetype)initWithRef:(id)ref {
+ if (self) {
+ __ref = ref;
+ self = [super initWithDomain:@"go" code:1 userInfo:@{NSLocalizedDescriptionKey: [self error]}];
+ }
+ return self;
+}
+
+- (NSString*)error {
+ int32_t refnum = go_seq_go_to_refnum(self._ref);
+ nstring r0 = proxy_error_Error(refnum);
+ NSString *_ret0_ = go_seq_to_objc_string(r0);
+ return _ret0_;
+}
+
+@end
+
+
+
+nstring cproxy_error_Error(int32_t refnum) {
+ @autoreleasepool {
+ Universeerror* o = go_seq_objc_from_refnum(refnum);
+ NSString* ret0_;
+ ret0_ = [o localizedDescription];
+ nstring _ret0_ = go_seq_from_objc_string(ret0_);
+ return _ret0_;
+ }
+}
+
+__attribute__((constructor)) static void init() {
+ init_seq();
+}