Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
func communicateJava(input interface{}) (interface{}, error) {
inBytes, err := json.Marshal(input)
inputStr := string(inBytes)
goRequest <- inputStr
respStr := <-javaResponse
var resp interface{}
err = json.Unmarshal([]byte(respStr), &resp)
//export Java_Test_start
func Java_Test_start(env *C.JNIEnv, clazz C.jclass) {
log.SetPrefix("GO - ")
go func() {
//export Java_Test_writeResponse
func Java_Test_writeResponse(env *C.JNIEnv, clazz C.jclass, input C.jstring) {
a := C.convert_to_cstring(env, input)
b := C.GoString(a)
javaResponse <- b
//export Java_Test_readRequest
func Java_Test_readRequest(env *C.JNIEnv, clazz C.jclass) C.jstring {
input := <-goRequest
cstr := C.CString(input)
cjstring := C.convert_to_jstring(env, cstr)
return cjstring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.