Skip to content

Instantly share code, notes, and snippets.

@mustafaakin
Created June 6, 2018 08:19
Show Gist options
  • Save mustafaakin/28b2660b533f0e903c959da14bdbad26 to your computer and use it in GitHub Desktop.
Save mustafaakin/28b2660b533f0e903c959da14bdbad26 to your computer and use it in GitHub Desktop.
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() {
lambda.Start(communicateJava)
}()
}
//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