Before this CL, calling overloaded methods on reverse bound Java classes and interfaces involved confusing and ugly name mangling. If a set of methods with the same name differed only in argument count, the mangling was simply adding the argument count to the name: func F() func F1(int32) But if two or more methods had the same number of arguments, the type had to be appended: func (...) F() int32 func (...) F1(int32) (int32, error) func (...) F__I(int32, int32) func (...) F__JLjava_util_concurrent_TimeUnit_2(int64, concurrent.TimeUnit) This CL sacrifices a bit of type safety and performance to regain the convenience and simplicity of Go by resolving overloaded method dispatch at runtime. Overloaded Java methods are combined to one Go method that, when invoked, determines the correct Java method variant at runtime. The signature of the Go method is compatible with every Java method with that name. For the example above, the single Go method becomes the most general func (...) F(...interface{}) (interface{}, error) The method is variadic to cover function with a varying number of arguments, and it returns interface{} to cover int32, int64 and no argument. Finally, it returns an error to cover the variant that returns an error. The generator tries to be specific; for example func G1(int32) int32 func G2(int32, int32) int32 becomes func G(int32, ...int32) int32 Overriding Java methods in Go is changed to use the Go parameter types to determine to correct Java method. To avoid name clashes when overriding multiple overloaded methods, trailing underscores in the method name are ignored when matching Java methods. See the Get methods of GoFuture in bind/testpkg/javapkg for an example. Change-Id: I6ac3e024141daa8fc2c35187865c5d7a63368094 Reviewed-on: https://go-review.googlesource.com/35186 Reviewed-by: David Crawshaw <crawshaw@golang.org>
92 lines
3.1 KiB
Plaintext
92 lines
3.1 KiB
Plaintext
// File is generated by gobind. Do not edit.
|
|
|
|
#include <jni.h>
|
|
#include "seq.h"
|
|
|
|
extern void init_proxies();
|
|
|
|
typedef struct ret_jint {
|
|
jint res;
|
|
jint exc;
|
|
} ret_jint;
|
|
typedef struct ret_jboolean {
|
|
jboolean res;
|
|
jint exc;
|
|
} ret_jboolean;
|
|
typedef struct ret_jshort {
|
|
jshort res;
|
|
jint exc;
|
|
} ret_jshort;
|
|
typedef struct ret_jchar {
|
|
jchar res;
|
|
jint exc;
|
|
} ret_jchar;
|
|
typedef struct ret_jbyte {
|
|
jbyte res;
|
|
jint exc;
|
|
} ret_jbyte;
|
|
typedef struct ret_jlong {
|
|
jlong res;
|
|
jint exc;
|
|
} ret_jlong;
|
|
typedef struct ret_jfloat {
|
|
jfloat res;
|
|
jint exc;
|
|
} ret_jfloat;
|
|
typedef struct ret_jdouble {
|
|
jdouble res;
|
|
jint exc;
|
|
} ret_jdouble;
|
|
typedef struct ret_nstring {
|
|
nstring res;
|
|
jint exc;
|
|
} ret_nstring;
|
|
typedef struct ret_nbyteslice {
|
|
nbyteslice res;
|
|
jint exc;
|
|
} ret_nbyteslice;
|
|
|
|
extern jint cproxy_java_lang_Runnable_run(jint this);
|
|
extern ret_jint cproxy_java_io_InputStream_read__(jint this);
|
|
extern ret_jint cproxy_java_io_InputStream_read___3B(jint this, nbyteslice a0);
|
|
extern ret_jint cproxy_java_io_InputStream_read___3BII(jint this, nbyteslice a0, jint a1, jint a2);
|
|
extern ret_jint cproxy_java_util_concurrent_Future_get__(jint this);
|
|
extern ret_jint cproxy_java_util_concurrent_Future_get__JLjava_util_concurrent_TimeUnit_2(jint this, jlong a0, jint a1);
|
|
extern ret_jint cproxy_java_Future_get__(jint this);
|
|
extern ret_jint csuper_java_Future_get__(jint this);
|
|
extern ret_jint cproxy_java_Future_get__JLjava_util_concurrent_TimeUnit_2(jint this, jlong a0, jint a1);
|
|
extern ret_jint csuper_java_Future_get__JLjava_util_concurrent_TimeUnit_2(jint this, jlong a0, jint a1);
|
|
extern ret_jint cproxy_java_InputStream_read__(jint this);
|
|
extern ret_jint csuper_java_InputStream_read__(jint this);
|
|
extern ret_jint cproxy_java_InputStream_read___3B(jint this, nbyteslice a0);
|
|
extern ret_jint csuper_java_InputStream_read___3B(jint this, nbyteslice a0);
|
|
extern ret_jint cproxy_java_InputStream_read___3BII(jint this, nbyteslice a0, jint a1, jint a2);
|
|
extern ret_jint csuper_java_InputStream_read___3BII(jint this, nbyteslice a0, jint a1, jint a2);
|
|
extern jint cproxy_java_Runnable_run(jint this);
|
|
extern jint csuper_java_Runnable_run(jint this);
|
|
extern jint cproxy_java_io_Console_flush(jint this);
|
|
extern ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_2(jint a0);
|
|
extern ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfInt_2(jint a0);
|
|
extern ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfLong_2(jint a0);
|
|
extern ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfDouble_2(jint a0);
|
|
extern ret_jint cproxy_s_java_lang_System_console();
|
|
// JNI function headers for the Go <=> Java bridge.
|
|
// gobind -lang=java classes
|
|
//
|
|
// File is generated by gobind. Do not edit.
|
|
|
|
#ifndef __Java_H__
|
|
#define __Java_H__
|
|
|
|
#include <jni.h>
|
|
|
|
extern jclass proxy_class_java_Future;
|
|
extern jmethodID proxy_class_java_Future_cons;
|
|
extern jclass proxy_class_java_InputStream;
|
|
extern jmethodID proxy_class_java_InputStream_cons;
|
|
extern jclass proxy_class_java_Object;
|
|
extern jmethodID proxy_class_java_Object_cons;
|
|
extern jclass proxy_class_java_Runnable;
|
|
extern jmethodID proxy_class_java_Runnable_cons;
|
|
#endif
|