2016-09-16 19:19:01 +02:00
|
|
|
// File is generated by gobind. Do not edit.
|
|
|
|
|
|
|
|
#include <jni.h>
|
|
|
|
#include "seq.h"
|
|
|
|
#include "classes.h"
|
|
|
|
|
|
|
|
static jclass class_java_lang_Runnable;
|
|
|
|
static jmethodID m_java_lang_Runnable_run;
|
|
|
|
static jclass class_java_io_InputStream;
|
|
|
|
static jmethodID m_java_io_InputStream_read__;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
static jmethodID m_java_io_InputStream_read___3B;
|
|
|
|
static jmethodID m_java_io_InputStream_read___3BII;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_io_InputStream_toString;
|
2016-09-16 19:19:01 +02:00
|
|
|
static jclass class_java_util_concurrent_Future;
|
|
|
|
static jmethodID m_java_util_concurrent_Future_get__;
|
|
|
|
static jmethodID m_java_util_concurrent_Future_get__JLjava_util_concurrent_TimeUnit_2;
|
|
|
|
static jclass class_java_lang_Object;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_lang_Object_toString;
|
2016-09-16 19:19:01 +02:00
|
|
|
static jclass class_java_util_concurrent_TimeUnit;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_util_concurrent_TimeUnit_toString;
|
2017-01-16 13:59:48 +01:00
|
|
|
static jclass class_java_util_Spliterators;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
static jmethodID m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_2;
|
2017-01-16 13:59:48 +01:00
|
|
|
static jmethodID m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfInt_2;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
static jmethodID m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfLong_2;
|
|
|
|
static jmethodID m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfDouble_2;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_util_Spliterators_toString;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_2(jint a0) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
jobject _a0 = go_seq_from_refnum(env, a0, NULL, NULL);
|
|
|
|
jobject res = (*env)->CallStaticObjectMethod(env, class_java_util_Spliterators, m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_2, _a0);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-16 13:59:48 +01:00
|
|
|
ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfInt_2(jint a0) {
|
2016-12-26 20:47:09 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
jobject _a0 = go_seq_from_refnum(env, a0, NULL, NULL);
|
2017-01-16 13:59:48 +01:00
|
|
|
jobject res = (*env)->CallStaticObjectMethod(env, class_java_util_Spliterators, m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfInt_2, _a0);
|
2016-12-26 20:47:09 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfLong_2(jint a0) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
jobject _a0 = go_seq_from_refnum(env, a0, NULL, NULL);
|
|
|
|
jobject res = (*env)->CallStaticObjectMethod(env, class_java_util_Spliterators, m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfLong_2, _a0);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_jint cproxy_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfDouble_2(jint a0) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
jobject _a0 = go_seq_from_refnum(env, a0, NULL, NULL);
|
|
|
|
jobject res = (*env)->CallStaticObjectMethod(env, class_java_util_Spliterators, m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfDouble_2, _a0);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-16 13:59:48 +01:00
|
|
|
static jclass class_java_lang_System;
|
|
|
|
static jmethodID m_s_java_lang_System_console;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_lang_System_toString;
|
2017-01-16 13:59:48 +01:00
|
|
|
ret_jint cproxy_s_java_lang_System_console() {
|
2017-01-01 19:55:42 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(0);
|
2017-01-16 13:59:48 +01:00
|
|
|
jobject res = (*env)->CallStaticObjectMethod(env, class_java_lang_System, m_s_java_lang_System_console);
|
2017-01-01 19:55:42 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
static jclass class_java_Future;
|
|
|
|
static jclass sclass_java_Future;
|
|
|
|
static jmethodID m_java_Future_get__;
|
|
|
|
static jmethodID sm_java_Future_get__;
|
|
|
|
static jmethodID m_java_Future_get__JLjava_util_concurrent_TimeUnit_2;
|
|
|
|
static jmethodID sm_java_Future_get__JLjava_util_concurrent_TimeUnit_2;
|
|
|
|
static jclass class_java_InputStream;
|
|
|
|
static jclass sclass_java_InputStream;
|
|
|
|
static jmethodID m_java_InputStream_read__;
|
|
|
|
static jmethodID sm_java_InputStream_read__;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
static jmethodID m_java_InputStream_read___3B;
|
|
|
|
static jmethodID sm_java_InputStream_read___3B;
|
|
|
|
static jmethodID m_java_InputStream_read___3BII;
|
|
|
|
static jmethodID sm_java_InputStream_read___3BII;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_InputStream_toString;
|
|
|
|
static jmethodID sm_java_InputStream_toString;
|
2017-01-01 22:43:46 +01:00
|
|
|
static jclass class_java_Object;
|
|
|
|
static jclass sclass_java_Object;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_Object_toString;
|
|
|
|
static jmethodID sm_java_Object_toString;
|
2017-01-01 22:43:46 +01:00
|
|
|
static jclass class_java_Runnable;
|
|
|
|
static jclass sclass_java_Runnable;
|
|
|
|
static jmethodID m_java_Runnable_run;
|
|
|
|
static jmethodID sm_java_Runnable_run;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
static jclass class_java_util_Iterator;
|
|
|
|
static jclass class_java_util_Spliterator;
|
2017-01-01 19:55:42 +01:00
|
|
|
static jclass class_java_util_PrimitiveIterator_OfInt;
|
|
|
|
static jclass class_java_util_Spliterator_OfInt;
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
static jclass class_java_util_PrimitiveIterator_OfLong;
|
|
|
|
static jclass class_java_util_Spliterator_OfLong;
|
|
|
|
static jclass class_java_util_PrimitiveIterator_OfDouble;
|
|
|
|
static jclass class_java_util_Spliterator_OfDouble;
|
2017-01-01 19:55:42 +01:00
|
|
|
static jclass class_java_io_Console;
|
|
|
|
static jmethodID m_java_io_Console_flush;
|
2017-01-16 20:10:54 +01:00
|
|
|
static jmethodID m_java_io_Console_toString;
|
2016-09-16 19:19:01 +02:00
|
|
|
|
|
|
|
void init_proxies() {
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(20);
|
2016-09-16 19:19:01 +02:00
|
|
|
jclass clazz;
|
2017-01-27 19:08:31 +01:00
|
|
|
clazz = go_seq_find_class("java/lang/Runnable");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_lang_Runnable = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_java_lang_Runnable_run = go_seq_get_method_id(clazz, "run", "()V");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/io/InputStream");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_io_InputStream = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_java_io_InputStream_read__ = go_seq_get_method_id(clazz, "read", "()I");
|
|
|
|
m_java_io_InputStream_read___3B = go_seq_get_method_id(clazz, "read", "([B)I");
|
|
|
|
m_java_io_InputStream_read___3BII = go_seq_get_method_id(clazz, "read", "([BII)I");
|
|
|
|
m_java_io_InputStream_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/concurrent/Future");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_concurrent_Future = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_java_util_concurrent_Future_get__ = go_seq_get_method_id(clazz, "get", "()Ljava/lang/Object;");
|
|
|
|
m_java_util_concurrent_Future_get__JLjava_util_concurrent_TimeUnit_2 = go_seq_get_method_id(clazz, "get", "(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/lang/Object");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_lang_Object = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_java_lang_Object_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/concurrent/TimeUnit");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_concurrent_TimeUnit = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_java_util_concurrent_TimeUnit_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/Spliterators");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_Spliterators = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_2 = go_seq_get_static_method_id(clazz, "iterator", "(Ljava/util/Spliterator;)Ljava/util/Iterator;");
|
|
|
|
m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfInt_2 = go_seq_get_static_method_id(clazz, "iterator", "(Ljava/util/Spliterator$OfInt;)Ljava/util/PrimitiveIterator$OfInt;");
|
|
|
|
m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfLong_2 = go_seq_get_static_method_id(clazz, "iterator", "(Ljava/util/Spliterator$OfLong;)Ljava/util/PrimitiveIterator$OfLong;");
|
|
|
|
m_s_java_util_Spliterators_iterator__Ljava_util_Spliterator_00024OfDouble_2 = go_seq_get_static_method_id(clazz, "iterator", "(Ljava/util/Spliterator$OfDouble;)Ljava/util/PrimitiveIterator$OfDouble;");
|
|
|
|
m_java_util_Spliterators_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/lang/System");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_lang_System = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_s_java_lang_System_console = go_seq_get_static_method_id(clazz, "console", "()Ljava/io/Console;");
|
|
|
|
m_java_lang_System_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/Future");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_Future = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
sclass_java_Future = (*env)->GetSuperclass(env, clazz);
|
|
|
|
sclass_java_Future = (*env)->NewGlobalRef(env, sclass_java_Future);
|
|
|
|
m_java_Future_get__ = go_seq_get_method_id(clazz, "get", "()Ljava/lang/Object;");
|
|
|
|
sm_java_Future_get__ = go_seq_get_method_id(sclass_java_Future, "get", "()Ljava/lang/Object;");
|
|
|
|
m_java_Future_get__JLjava_util_concurrent_TimeUnit_2 = go_seq_get_method_id(clazz, "get", "(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;");
|
|
|
|
sm_java_Future_get__JLjava_util_concurrent_TimeUnit_2 = go_seq_get_method_id(sclass_java_Future, "get", "(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/InputStream");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_InputStream = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
sclass_java_InputStream = (*env)->GetSuperclass(env, clazz);
|
|
|
|
sclass_java_InputStream = (*env)->NewGlobalRef(env, sclass_java_InputStream);
|
|
|
|
m_java_InputStream_read__ = go_seq_get_method_id(clazz, "read", "()I");
|
|
|
|
sm_java_InputStream_read__ = go_seq_get_method_id(sclass_java_InputStream, "read", "()I");
|
|
|
|
m_java_InputStream_read___3B = go_seq_get_method_id(clazz, "read", "([B)I");
|
|
|
|
sm_java_InputStream_read___3B = go_seq_get_method_id(sclass_java_InputStream, "read", "([B)I");
|
|
|
|
m_java_InputStream_read___3BII = go_seq_get_method_id(clazz, "read", "([BII)I");
|
|
|
|
sm_java_InputStream_read___3BII = go_seq_get_method_id(sclass_java_InputStream, "read", "([BII)I");
|
|
|
|
m_java_InputStream_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
sm_java_InputStream_toString = go_seq_get_method_id(sclass_java_InputStream, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/Object");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_Object = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
sclass_java_Object = (*env)->GetSuperclass(env, clazz);
|
|
|
|
sclass_java_Object = (*env)->NewGlobalRef(env, sclass_java_Object);
|
|
|
|
m_java_Object_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
sm_java_Object_toString = go_seq_get_method_id(sclass_java_Object, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/Runnable");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_Runnable = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
sclass_java_Runnable = (*env)->GetSuperclass(env, clazz);
|
|
|
|
sclass_java_Runnable = (*env)->NewGlobalRef(env, sclass_java_Runnable);
|
|
|
|
m_java_Runnable_run = go_seq_get_method_id(clazz, "run", "()V");
|
|
|
|
sm_java_Runnable_run = go_seq_get_method_id(sclass_java_Runnable, "run", "()V");
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/Iterator");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_Iterator = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/Spliterator");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_Spliterator = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/PrimitiveIterator$OfInt");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_PrimitiveIterator_OfInt = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/Spliterator$OfInt");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_Spliterator_OfInt = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/PrimitiveIterator$OfLong");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_PrimitiveIterator_OfLong = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/Spliterator$OfLong");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_Spliterator_OfLong = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/PrimitiveIterator$OfDouble");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_PrimitiveIterator_OfDouble = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/util/Spliterator$OfDouble");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_util_Spliterator_OfDouble = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
}
|
|
|
|
clazz = go_seq_find_class("java/io/Console");
|
|
|
|
if (clazz != NULL) {
|
|
|
|
class_java_io_Console = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
m_java_io_Console_flush = go_seq_get_method_id(clazz, "flush", "()V");
|
|
|
|
m_java_io_Console_toString = go_seq_get_method_id(clazz, "toString", "()Ljava/lang/String;");
|
|
|
|
}
|
2016-09-16 19:19:01 +02:00
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
}
|
|
|
|
|
|
|
|
jint cproxy_java_lang_Runnable_run(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
(*env)->CallVoidMethod(env, _this, m_java_lang_Runnable_run);
|
2016-09-19 12:44:13 +02:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
return _exc_ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_jint cproxy_java_io_InputStream_read__(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jint res = (*env)->CallIntMethod(env, _this, m_java_io_InputStream_read__);
|
2016-09-19 12:44:13 +02:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
2016-12-19 23:46:07 +01:00
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
2016-09-16 19:19:01 +02:00
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
ret_jint cproxy_java_io_InputStream_read___3B(jint this, nbyteslice a0) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(2);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jbyteArray _a0 = go_seq_to_java_bytearray(env, a0, 0);
|
|
|
|
jint res = (*env)->CallIntMethod(env, _this, m_java_io_InputStream_read___3B, _a0);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_jint cproxy_java_io_InputStream_read___3BII(jint this, nbyteslice a0, jint a1, jint a2) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(4);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jbyteArray _a0 = go_seq_to_java_bytearray(env, a0, 0);
|
|
|
|
jint _a1 = a1;
|
|
|
|
jint _a2 = a2;
|
|
|
|
jint res = (*env)->CallIntMethod(env, _this, m_java_io_InputStream_read___3BII, _a0, _a1, _a2);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:10:54 +01:00
|
|
|
ret_nstring cproxy_java_io_InputStream_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_io_InputStream_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
ret_jint cproxy_java_util_concurrent_Future_get__(jint this) {
|
2016-09-16 19:19:01 +02:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject res = (*env)->CallObjectMethod(env, _this, m_java_util_concurrent_Future_get__);
|
2016-09-19 12:44:13 +02:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
2016-12-19 23:46:07 +01:00
|
|
|
if (_exc != NULL) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
res = NULL;
|
2016-12-19 23:46:07 +01:00
|
|
|
}
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
2016-09-16 19:19:01 +02:00
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
ret_jint cproxy_java_util_concurrent_Future_get__JLjava_util_concurrent_TimeUnit_2(jint this, jlong a0, jint a1) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(3);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jlong _a0 = a0;
|
|
|
|
jobject _a1 = go_seq_from_refnum(env, a1, NULL, NULL);
|
|
|
|
jobject res = (*env)->CallObjectMethod(env, _this, m_java_util_concurrent_Future_get__JLjava_util_concurrent_TimeUnit_2, _a0, _a1);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:10:54 +01:00
|
|
|
ret_nstring cproxy_java_lang_Object_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_lang_Object_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_nstring cproxy_java_util_concurrent_TimeUnit_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_util_concurrent_TimeUnit_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_nstring cproxy_java_util_Spliterators_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_util_Spliterators_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_nstring cproxy_java_lang_System_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_lang_System_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
ret_jint cproxy_java_Future_get__(jint this) {
|
2016-09-16 19:19:01 +02:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
jobject res = (*env)->CallObjectMethod(env, _this, m_java_Future_get__);
|
2016-09-19 12:44:13 +02:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
2016-12-19 23:46:07 +01:00
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
2016-09-16 19:19:01 +02:00
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
ret_jint csuper_java_Future_get__(jint this) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
jobject res = (*env)->CallNonvirtualObjectMethod(env, _this, sclass_java_Future, sm_java_Future_get__);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
ret_jint cproxy_java_Future_get__JLjava_util_concurrent_TimeUnit_2(jint this, jlong a0, jint a1) {
|
2016-09-16 19:19:01 +02:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(3);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jlong _a0 = a0;
|
|
|
|
jobject _a1 = go_seq_from_refnum(env, a1, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
jobject res = (*env)->CallObjectMethod(env, _this, m_java_Future_get__JLjava_util_concurrent_TimeUnit_2, _a0, _a1);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
ret_jint csuper_java_Future_get__JLjava_util_concurrent_TimeUnit_2(jint this, jlong a0, jint a1) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(3);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jlong _a0 = a0;
|
|
|
|
jobject _a1 = go_seq_from_refnum(env, a1, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
jobject res = (*env)->CallNonvirtualObjectMethod(env, _this, sclass_java_Future, sm_java_Future_get__JLjava_util_concurrent_TimeUnit_2, _a0, _a1);
|
2016-09-19 12:44:13 +02:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
2016-12-19 23:46:07 +01:00
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
2016-09-16 19:19:01 +02:00
|
|
|
jint _res = go_seq_to_refnum(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
ret_jint cproxy_java_InputStream_read__(jint this) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
jint res = (*env)->CallIntMethod(env, _this, m_java_InputStream_read__);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
ret_jint csuper_java_InputStream_read__(jint this) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
jint res = (*env)->CallNonvirtualIntMethod(env, _this, sclass_java_InputStream, sm_java_InputStream_read__);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
ret_jint cproxy_java_InputStream_read___3B(jint this, nbyteslice a0) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(2);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jbyteArray _a0 = go_seq_to_java_bytearray(env, a0, 0);
|
|
|
|
jint res = (*env)->CallIntMethod(env, _this, m_java_InputStream_read___3B, _a0);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_jint csuper_java_InputStream_read___3B(jint this, nbyteslice a0) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(2);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jbyteArray _a0 = go_seq_to_java_bytearray(env, a0, 0);
|
|
|
|
jint res = (*env)->CallNonvirtualIntMethod(env, _this, sclass_java_InputStream, sm_java_InputStream_read___3B, _a0);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_jint cproxy_java_InputStream_read___3BII(jint this, nbyteslice a0, jint a1, jint a2) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(4);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jbyteArray _a0 = go_seq_to_java_bytearray(env, a0, 0);
|
|
|
|
jint _a1 = a1;
|
|
|
|
jint _a2 = a2;
|
|
|
|
jint res = (*env)->CallIntMethod(env, _this, m_java_InputStream_read___3BII, _a0, _a1, _a2);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_jint csuper_java_InputStream_read___3BII(jint this, nbyteslice a0, jint a1, jint a2) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(4);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jbyteArray _a0 = go_seq_to_java_bytearray(env, a0, 0);
|
|
|
|
jint _a1 = a1;
|
|
|
|
jint _a2 = a2;
|
|
|
|
jint res = (*env)->CallNonvirtualIntMethod(env, _this, sclass_java_InputStream, sm_java_InputStream_read___3BII, _a0, _a1, _a2);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = 0;
|
|
|
|
}
|
|
|
|
jint _res = res;
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_jint __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:10:54 +01:00
|
|
|
ret_nstring cproxy_java_InputStream_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_InputStream_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_nstring csuper_java_InputStream_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallNonvirtualObjectMethod(env, _this, sclass_java_InputStream, sm_java_InputStream_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_nstring cproxy_java_Object_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_Object_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret_nstring csuper_java_Object_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallNonvirtualObjectMethod(env, _this, sclass_java_Object, sm_java_Object_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
jint cproxy_java_Runnable_run(jint this) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
(*env)->CallVoidMethod(env, _this, m_java_Runnable_run);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
return _exc_ref;
|
|
|
|
}
|
|
|
|
|
2017-01-01 22:43:46 +01:00
|
|
|
jint csuper_java_Runnable_run(jint this) {
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
2017-01-01 22:43:46 +01:00
|
|
|
(*env)->CallNonvirtualVoidMethod(env, _this, sclass_java_Runnable, sm_java_Runnable_run);
|
bind,cmd,internal: generate reverse bindings for exported Go structs
Before this CL, the type of the implicit "this" parameter to Java methods
implemented in Go could only be a super class of the generated Java
class. For example, the following GoRunnable type is an implementation of
the Java interface java.lang.Runnable with a toString method:
package somepkg
import "Java/java/lang"
type GoRunnable struct {
lang.Runnable
}
func (r *GoRunnable) ToString(this lang.Runnable) string {
...
}
The "this" parameter is implicit in the sense that the reverse generator
automatically fills it with a reference to the Java instance of
GoRunnable.
Note that "this" has the type Java/java/lang.Runnable, not
Java/go/somepkg.GoRunnable, which renders it impossible to call Java
methods and functions that expect GoRunnable. The most practical example
of this is the Android databinding libraries.
This CL changes the implicit this parameter to always match the exact
type. In the example, the toString implementation becomes:
import gopkg "Java/go/somepkg"
func (r *GoRunnable) ToString(this gopkg.GoRunnable) string {
...
}
One strategy would be to simply treat the generated Java classes
(GoRunnable in our example) as any other Java class and import it
through javap. However, since the Java classes are generated after
importing, this present a chicken-and-egg problem.
Instead, use the newly added support for structs with embedded prefixed types
and synthesize class descriptors for every exported Go struct type.
Change-Id: Ic5ce4a151312bd89f91798ed4088c9959225b448
Reviewed-on: https://go-review.googlesource.com/34776
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-12-31 16:41:36 +01:00
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
return _exc_ref;
|
|
|
|
}
|
|
|
|
|
2017-01-01 19:55:42 +01:00
|
|
|
jint cproxy_java_io_Console_flush(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
(*env)->CallVoidMethod(env, _this, m_java_io_Console_flush);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
return _exc_ref;
|
|
|
|
}
|
|
|
|
|
2017-01-16 20:10:54 +01:00
|
|
|
ret_nstring cproxy_java_io_Console_toString(jint this) {
|
|
|
|
JNIEnv *env = go_seq_push_local_frame(1);
|
|
|
|
// Must be a Java object
|
|
|
|
jobject _this = go_seq_from_refnum(env, this, NULL, NULL);
|
|
|
|
jstring res = (*env)->CallObjectMethod(env, _this, m_java_io_Console_toString);
|
|
|
|
jobject _exc = go_seq_get_exception(env);
|
|
|
|
int32_t _exc_ref = go_seq_to_refnum(env, _exc);
|
|
|
|
if (_exc != NULL) {
|
|
|
|
res = NULL;
|
|
|
|
}
|
|
|
|
nstring _res = go_seq_from_java_string(env, res);
|
|
|
|
go_seq_pop_local_frame(env);
|
|
|
|
ret_nstring __res = {_res, _exc_ref};
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
2016-09-16 19:19:01 +02:00
|
|
|
// JNI functions for the Go <=> Java bridge.
|
|
|
|
// gobind -lang=java classes
|
|
|
|
//
|
|
|
|
// File is generated by gobind. Do not edit.
|
|
|
|
|
|
|
|
#include <android/log.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "seq.h"
|
|
|
|
#include "_cgo_export.h"
|
|
|
|
#include "java.h"
|
|
|
|
|
|
|
|
jclass proxy_class_java_Future;
|
|
|
|
jmethodID proxy_class_java_Future_cons;
|
|
|
|
jclass proxy_class_java_InputStream;
|
|
|
|
jmethodID proxy_class_java_InputStream_cons;
|
|
|
|
jclass proxy_class_java_Object;
|
|
|
|
jmethodID proxy_class_java_Object_cons;
|
|
|
|
jclass proxy_class_java_Runnable;
|
|
|
|
jmethodID proxy_class_java_Runnable_cons;
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Java__1init(JNIEnv *env, jclass _unused) {
|
2016-09-16 19:19:01 +02:00
|
|
|
jclass clazz;
|
2017-01-01 22:43:46 +01:00
|
|
|
clazz = (*env)->FindClass(env, "java/Future");
|
2016-09-16 19:19:01 +02:00
|
|
|
proxy_class_java_Future = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
proxy_class_java_Future_cons = (*env)->GetMethodID(env, clazz, "<init>", "(Lgo/Seq$Ref;)V");
|
2017-01-01 22:43:46 +01:00
|
|
|
clazz = (*env)->FindClass(env, "java/Object");
|
2016-09-27 17:59:07 +02:00
|
|
|
proxy_class_java_Object = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
proxy_class_java_Object_cons = (*env)->GetMethodID(env, clazz, "<init>", "(Lgo/Seq$Ref;)V");
|
2017-01-01 22:43:46 +01:00
|
|
|
clazz = (*env)->FindClass(env, "java/Runnable");
|
2016-09-16 19:19:01 +02:00
|
|
|
proxy_class_java_Runnable = (*env)->NewGlobalRef(env, clazz);
|
|
|
|
proxy_class_java_Runnable_cons = (*env)->GetMethodID(env, clazz, "<init>", "(Lgo/Seq$Ref;)V");
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Java_newInputStream(JNIEnv* env, jclass _clazz) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t r0 = proxyjava__NewInputStream();
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, r0, proxy_class_java_InputStream, proxy_class_java_InputStream_cons);
|
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Future__1_1New(JNIEnv *env, jclass clazz) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t refnum = new_java_Future();
|
|
|
|
return go_seq_from_refnum(env, refnum, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Future_get__(JNIEnv* env, jobject __this__) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, __this__);
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
struct proxyjava_Future_Get_return res = proxyjava_Future_Get(o);
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, res.r0, NULL, NULL);
|
|
|
|
jobject _r1 = go_seq_from_refnum(env, res.r1, proxy_class__error, proxy_class__error_cons);
|
|
|
|
go_seq_maybe_throw_exception(env, _r1);
|
2016-09-16 19:19:01 +02:00
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Future_get__JLjava_util_concurrent_TimeUnit_2(JNIEnv* env, jobject __this__, jlong p0, jobject p1) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, __this__);
|
|
|
|
int64_t _p0 = (int64_t)p0;
|
|
|
|
int32_t _p1 = go_seq_to_refnum(env, p1);
|
internal,bind: resolve overloaded methods at runtime
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>
2017-01-16 14:08:12 +01:00
|
|
|
struct proxyjava_Future_Get__return res = proxyjava_Future_Get_(o, _p0, _p1);
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, res.r0, NULL, NULL);
|
|
|
|
jobject _r1 = go_seq_from_refnum(env, res.r1, proxy_class__error, proxy_class__error_cons);
|
|
|
|
go_seq_maybe_throw_exception(env, _r1);
|
2016-09-16 19:19:01 +02:00
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Future_setFuture(JNIEnv *env, jobject this, jobject v) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _v = go_seq_to_refnum(env, v);
|
|
|
|
proxyjava_Future_Future_Set(o, _v);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Future_getFuture(JNIEnv *env, jobject this) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t r0 = proxyjava_Future_Future_Get(o);
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, r0, NULL, NULL);
|
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_InputStream__1_1NewInputStream(JNIEnv *env, jclass clazz) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t refnum = proxyjava__NewInputStream();
|
|
|
|
return go_seq_from_refnum(env, refnum, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jint JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_InputStream_read__(JNIEnv* env, jobject __this__) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, __this__);
|
|
|
|
struct proxyjava_InputStream_Read_return res = proxyjava_InputStream_Read(o);
|
|
|
|
jint _r0 = (jint)res.r0;
|
|
|
|
jobject _r1 = go_seq_from_refnum(env, res.r1, proxy_class__error, proxy_class__error_cons);
|
|
|
|
go_seq_maybe_throw_exception(env, _r1);
|
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_InputStream_setInputStream(JNIEnv *env, jobject this, jobject v) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _v = go_seq_to_refnum(env, v);
|
|
|
|
proxyjava_InputStream_InputStream_Set(o, _v);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_InputStream_getInputStream(JNIEnv *env, jobject this) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t r0 = proxyjava_InputStream_InputStream_Get(o);
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, r0, NULL, NULL);
|
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
2016-09-27 17:59:07 +02:00
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Object__1_1New(JNIEnv *env, jclass clazz) {
|
2016-09-27 17:59:07 +02:00
|
|
|
int32_t refnum = new_java_Object();
|
|
|
|
return go_seq_from_refnum(env, refnum, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2016-09-16 19:19:01 +02:00
|
|
|
JNIEXPORT void JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Object_setObject(JNIEnv *env, jobject this, jobject v) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _v = go_seq_to_refnum(env, v);
|
|
|
|
proxyjava_Object_Object_Set(o, _v);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Object_getObject(JNIEnv *env, jobject this) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t r0 = proxyjava_Object_Object_Get(o);
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, r0, NULL, NULL);
|
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Runnable__1_1New(JNIEnv *env, jclass clazz) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t refnum = new_java_Runnable();
|
|
|
|
return go_seq_from_refnum(env, refnum, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Runnable_run(JNIEnv* env, jobject __this__) {
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, __this__);
|
2016-10-20 15:33:05 +02:00
|
|
|
int32_t _this_ = go_seq_to_refnum(env, __this__);
|
|
|
|
proxyjava_Runnable_Run(o, _this_);
|
2016-09-16 19:19:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Runnable_setRunnable(JNIEnv *env, jobject this, jobject v) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t _v = go_seq_to_refnum(env, v);
|
|
|
|
proxyjava_Runnable_Runnable_Set(o, _v);
|
|
|
|
}
|
|
|
|
|
|
|
|
JNIEXPORT jobject JNICALL
|
2017-01-01 22:43:46 +01:00
|
|
|
Java_java_Runnable_getRunnable(JNIEnv *env, jobject this) {
|
2016-10-14 18:38:12 +02:00
|
|
|
int32_t o = go_seq_to_refnum_go(env, this);
|
2016-09-16 19:19:01 +02:00
|
|
|
int32_t r0 = proxyjava_Runnable_Runnable_Get(o);
|
|
|
|
jobject _r0 = go_seq_from_refnum(env, r0, NULL, NULL);
|
|
|
|
return _r0;
|
|
|
|
}
|
|
|
|
|