Merge "veyron/examples/pipetobrowser: Polish and performance improvements"
diff --git a/runtimes/google/ipc/jni/dispatcher.go b/runtimes/google/ipc/jni/dispatcher.go
index a913b3b..425a6fb 100644
--- a/runtimes/google/ipc/jni/dispatcher.go
+++ b/runtimes/google/ipc/jni/dispatcher.go
@@ -58,7 +58,7 @@
defer C.DetachCurrentThread(d.jVM)
// Call Java dispatcher's lookup() method.
- lid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, d.jDispatcher), "lookup", fmt.Sprintf("(%s)%s", util.StringSign, util.ObjectSign)))
+ lid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, d.jDispatcher), "lookup", fmt.Sprintf("(%s)%s", util.StringSign, util.ObjectSign)))
jObj := C.CallLookupMethod(env, d.jDispatcher, lid, C.jstring(util.JStringPtr(env, suffix)))
if err := util.JExceptionMsg(env); err != nil {
return nil, nil, fmt.Errorf("error invoking Java dispatcher's lookup() method: %v", err)
diff --git a/runtimes/google/ipc/jni/invoker.go b/runtimes/google/ipc/jni/invoker.go
index 0c9ba2a..0cda728 100644
--- a/runtimes/google/ipc/jni/invoker.go
+++ b/runtimes/google/ipc/jni/invoker.go
@@ -36,13 +36,13 @@
func newInvoker(env *C.JNIEnv, jVM *C.JavaVM, jObj C.jobject) (*invoker, error) {
// Create a new Java VDLInvoker object.
- cid := C.jmethodID(util.JMethodIDPtr(env, jVDLInvokerClass, "<init>", fmt.Sprintf("(%s)%s", util.ObjectSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jVDLInvokerClass, "<init>", fmt.Sprintf("(%s)%s", util.ObjectSign, util.VoidSign)))
jInvoker := C.CallNewInvokerObject(env, jVDLInvokerClass, cid, jObj)
if err := util.JExceptionMsg(env); err != nil {
return nil, fmt.Errorf("error creating Java VDLInvoker object: %v", err)
}
// Fetch the argGetter for the object.
- pid := C.jmethodID(util.JMethodIDPtr(env, jVDLInvokerClass, "getImplementedServices", fmt.Sprintf("()%s", util.ArraySign(util.StringSign))))
+ pid := C.jmethodID(util.JMethodIDPtrOrDie(env, jVDLInvokerClass, "getImplementedServices", fmt.Sprintf("()%s", util.ArraySign(util.StringSign))))
jPathArray := C.jobjectArray(C.CallGetInterfacePath(env, jInvoker, pid))
paths := util.GoStringArray(env, jPathArray)
getter, err := newArgGetter(paths)
@@ -108,7 +108,7 @@
err = fmt.Errorf("couldn't find VDL method %q with %d args", method, len(argptrs))
}
sCall := newServerCall(call, mArgs)
- cid := C.jmethodID(util.JMethodIDPtr(env, jServerCallClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jServerCallClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
jServerCall := C.CallNewServerCallObject(env, jServerCallClass, cid, C.jlong(util.PtrValue(sCall)))
util.GoRef(sCall) // unref-ed when jServerCall is garbage-collected
@@ -120,7 +120,7 @@
// Invoke the method.
const callSign = "Lcom/veyron2/ipc/ServerCall;"
const replySign = "Lcom/veyron/runtimes/google/VDLInvoker$InvokeReply;"
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, i.jInvoker), "invoke", fmt.Sprintf("(%s%s[%s)%s", util.StringSign, callSign, util.StringSign, replySign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, i.jInvoker), "invoke", fmt.Sprintf("(%s%s[%s)%s", util.StringSign, callSign, util.StringSign, replySign)))
jReply := C.CallInvokeMethod(env, i.jInvoker, mid, C.jstring(util.JStringPtr(env, util.CamelCase(method))), jServerCall, jArgs)
if err := util.JExceptionMsg(env); err != nil {
return nil, fmt.Errorf("error invoking Java method %q: %v", method, err)
diff --git a/runtimes/google/jni/util/util.go b/runtimes/google/jni/util/util.go
index 85e73a7..767d62c 100644
--- a/runtimes/google/jni/util/util.go
+++ b/runtimes/google/jni/util/util.go
@@ -180,7 +180,7 @@
func JThrowV(jEnv interface{}, err error) {
env := getEnv(jEnv)
verr := verror.Convert(err)
- id := C.jmethodID(JMethodIDPtr(env, jVeyronExceptionClass, "<init>", fmt.Sprintf("(%s%s)%s", StringSign, StringSign, VoidSign)))
+ id := C.jmethodID(JMethodIDPtrOrDie(env, jVeyronExceptionClass, "<init>", fmt.Sprintf("(%s%s)%s", StringSign, StringSign, VoidSign)))
obj := C.jthrowable(C.CallNewVeyronExceptionObject(env, jVeyronExceptionClass, id, C.jstring(JStringPtr(env, verr.Error())), C.jstring(JStringPtr(env, string(verr.ErrorID())))))
C.Throw(env, obj)
}
@@ -197,7 +197,7 @@
return nil
}
C.ExceptionClear(env)
- id := C.jmethodID(JMethodIDPtr(env, jThrowableClass, "getMessage", fmt.Sprintf("()%s", StringSign)))
+ id := C.jmethodID(JMethodIDPtrOrDie(env, jThrowableClass, "getMessage", fmt.Sprintf("()%s", StringSign)))
jMsg := C.CallGetExceptionMessage(env, C.jobject(e), id)
return errors.New(GoString(env, jMsg))
}
@@ -209,11 +209,7 @@
func JBoolField(jEnv, jObj interface{}, field string) bool {
env := getEnv(jEnv)
obj := getObject(jObj)
- cField := C.CString(field)
- defer C.free(unsafe.Pointer(cField))
- cSig := C.CString(BoolSign)
- defer C.free(unsafe.Pointer(cSig))
- fid := C.GetFieldID(env, C.GetObjectClass(env, obj), cField, cSig)
+ fid := C.jfieldID(JFieldIDPtrOrDie(env, C.GetObjectClass(env, obj), field, BoolSign))
return C.GetBooleanField(env, obj, fid) != C.JNI_FALSE
}
@@ -224,11 +220,7 @@
func JIntField(jEnv, jObj interface{}, field string) int {
env := getEnv(jEnv)
obj := getObject(jObj)
- cField := C.CString(field)
- defer C.free(unsafe.Pointer(cField))
- cSig := C.CString(IntSign)
- defer C.free(unsafe.Pointer(cSig))
- fid := C.GetFieldID(env, C.GetObjectClass(env, obj), cField, cSig)
+ fid := C.jfieldID(JFieldIDPtrOrDie(env, C.GetObjectClass(env, obj), field, IntSign))
return int(C.GetIntField(env, obj, fid))
}
@@ -240,11 +232,7 @@
func JStringField(jEnv, jObj interface{}, field string) string {
env := getEnv(jEnv)
obj := getObject(jObj)
- cField := C.CString(field)
- defer C.free(unsafe.Pointer(cField))
- cSig := C.CString(StringSign)
- defer C.free(unsafe.Pointer(cSig))
- fid := C.GetFieldID(env, C.GetObjectClass(env, obj), cField, cSig)
+ fid := C.jfieldID(JFieldIDPtrOrDie(env, C.GetObjectClass(env, obj), field, StringSign))
jStr := C.jstring(C.GetObjectField(env, obj, fid))
return GoString(env, jStr)
}
@@ -257,11 +245,7 @@
func JStringArrayField(jEnv, jObj interface{}, field string) []string {
env := getEnv(jEnv)
obj := getObject(jObj)
- cField := C.CString(field)
- defer C.free(unsafe.Pointer(cField))
- cSig := C.CString("[" + StringSign)
- defer C.free(unsafe.Pointer(cSig))
- fid := C.GetFieldID(env, C.GetObjectClass(env, obj), cField, cSig)
+ fid := C.jfieldID(JFieldIDPtrOrDie(env, C.GetObjectClass(env, obj), field, ArraySign(StringSign)))
jStrArray := C.jobjectArray(C.GetObjectField(env, obj, fid))
return GoStringArray(env, jStrArray)
}
@@ -274,11 +258,7 @@
func JByteArrayField(jEnv, jObj interface{}, field string) []byte {
env := getEnv(jEnv)
obj := getObject(jObj)
- cField := C.CString(field)
- defer C.free(unsafe.Pointer(cField))
- cSig := C.CString("[" + StringSign)
- defer C.free(unsafe.Pointer(cSig))
- fid := C.GetFieldID(env, C.GetObjectClass(env, obj), cField, cSig)
+ fid := C.jfieldID(JFieldIDPtrOrDie(env, C.GetObjectClass(env, obj), field, ArraySign(ByteSign)))
arr := C.jbyteArray(C.GetObjectField(env, obj, fid))
if arr == nil {
return nil
@@ -345,21 +325,43 @@
return
}
-// JMethodID returns the Java method ID for the given method.
+// JFieldIDPtrOrDie returns the Java field ID for the given field.
// NOTE: Because CGO creates package-local types and because this method may be
// invoked from a different package, Java types are passed in an empty interface
// and then cast into their package local types.
-func JMethodIDPtr(jEnv, jClass interface{}, name, signature string) unsafe.Pointer {
+func JFieldIDPtrOrDie(jEnv, jClass interface{}, name, sign string) unsafe.Pointer {
+ env := getEnv(jEnv)
+ class := getClass(jClass)
+ cName := C.CString(name)
+ defer C.free(unsafe.Pointer(cName))
+ cSign := C.CString(sign)
+ defer C.free(unsafe.Pointer(cSign))
+ ptr := unsafe.Pointer(C.GetFieldID(env, class, cName, cSign))
+ if err := JExceptionMsg(env); err != nil || ptr == nil {
+ panic(fmt.Sprintf("couldn't find field %s: %v", name, err))
+ }
+ return ptr
+}
+
+// JMethodIDPtrOrDie returns the Java method ID for the given method.
+// NOTE: Because CGO creates package-local types and because this method may be
+// invoked from a different package, Java types are passed in an empty interface
+// and then cast into their package local types.
+func JMethodIDPtrOrDie(jEnv, jClass interface{}, name, signature string) unsafe.Pointer {
env := getEnv(jEnv)
class := getClass(jClass)
cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))
cSignature := C.CString(signature)
defer C.free(unsafe.Pointer(cSignature))
- return unsafe.Pointer(C.GetMethodID(env, class, cName, cSignature))
+ ptr := unsafe.Pointer(C.GetMethodID(env, class, cName, cSignature))
+ if err := JExceptionMsg(env); err != nil || ptr == nil {
+ panic(fmt.Sprintf("couldn't find method %s: %v", name, err))
+ }
+ return ptr
}
-// JFindClassOrDie returns the global references to the Java class with the
+// JFindClasPtrsOrDie returns the global references to the Java class with the
// given pathname, or panic-s if the class cannot be found.
// NOTE: Because CGO creates package-local types and because this method may be
// invoked from a different package, Java types are passed in an empty interface
diff --git a/runtimes/google/security/jni/authorizer.go b/runtimes/google/security/jni/authorizer.go
index 9a00b91..e1bf576 100644
--- a/runtimes/google/security/jni/authorizer.go
+++ b/runtimes/google/security/jni/authorizer.go
@@ -65,11 +65,11 @@
defer C.DetachCurrentThread(a.jVM)
// Create a Java context.
util.GoRef(&context) // Un-refed when the Java Context object is finalized.
- cid := C.jmethodID(util.JMethodIDPtr(env, jContextImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jContextImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
jContext := C.CallAuthorizerNewContextObject(env, jContextImplClass, cid, C.jlong(util.PtrValue(&context)))
// Run Java Authorizer.
contextSign := "Lcom/veyron2/security/Context;"
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, a.jAuth), "authorize", fmt.Sprintf("(%s)%s", contextSign, util.VoidSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, a.jAuth), "authorize", fmt.Sprintf("(%s)%s", contextSign, util.VoidSign)))
if mid == nil {
return fmt.Errorf("Srdjan's error")
}
diff --git a/runtimes/google/security/jni/caveat.go b/runtimes/google/security/jni/caveat.go
index e3901dc..b09885a 100644
--- a/runtimes/google/security/jni/caveat.go
+++ b/runtimes/google/security/jni/caveat.go
@@ -58,10 +58,10 @@
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
util.GoRef(&context) // un-refed when the Java Context object is finalized.
- cid := C.jmethodID(util.JMethodIDPtr(env, jContextImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jContextImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
jContext := C.CallCaveatNewContextObject(env, jContextClass, cid, C.jlong(util.PtrValue(&context)))
contextSign := "Lcom/veyron2/security/Context;"
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jCaveat), "validate", fmt.Sprintf("(%s)%s", contextSign, util.VoidSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jCaveat), "validate", fmt.Sprintf("(%s)%s", contextSign, util.VoidSign)))
C.CallCaveatValidateMethod(env, c.jCaveat, mid, jContext)
return util.JExceptionMsg(env)
}
diff --git a/runtimes/google/security/jni/context.go b/runtimes/google/security/jni/context.go
index 57e6a31..533f2d9 100644
--- a/runtimes/google/security/jni/context.go
+++ b/runtimes/google/security/jni/context.go
@@ -62,7 +62,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "method", fmt.Sprintf("()%s", util.StringSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "method", fmt.Sprintf("()%s", util.StringSign)))
return util.GoString(env, C.CallContextStringMethod(env, c.jContext, mid))
}
@@ -70,7 +70,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "name", fmt.Sprintf("()%s", util.StringSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "name", fmt.Sprintf("()%s", util.StringSign)))
return util.GoString(env, C.CallContextStringMethod(env, c.jContext, mid))
}
@@ -78,7 +78,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "suffix", fmt.Sprintf("()%s", util.StringSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "suffix", fmt.Sprintf("()%s", util.StringSign)))
return util.GoString(env, C.CallContextStringMethod(env, c.jContext, mid))
}
@@ -86,7 +86,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "label", fmt.Sprintf("()%s", util.IntSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "label", fmt.Sprintf("()%s", util.IntSign)))
return security.Label(C.CallContextIntMethod(env, c.jContext, mid))
}
@@ -100,7 +100,7 @@
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
publicIDSign := "Lcom/veyron2/security/PublicID;"
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "localID", fmt.Sprintf("()%s", publicIDSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "localID", fmt.Sprintf("()%s", publicIDSign)))
jID := C.CallContextPublicIDMethod(env, c.jContext, mid)
return newPublicID(env, jID)
}
@@ -110,7 +110,7 @@
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
publicIDSign := "Lcom/veyron2/security/PublicID;"
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "remoteID", fmt.Sprintf("()%s", publicIDSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "remoteID", fmt.Sprintf("()%s", publicIDSign)))
jID := C.CallContextPublicIDMethod(env, c.jContext, mid)
return newPublicID(env, jID)
}
@@ -119,7 +119,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "localEndpoint", fmt.Sprintf("()%s", util.StringSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "localEndpoint", fmt.Sprintf("()%s", util.StringSign)))
// TODO(spetrovic): create a Java Endpoint interface.
epStr := util.GoString(env, C.CallContextStringMethod(env, c.jContext, mid))
ep, err := inaming.NewEndpoint(epStr)
@@ -133,7 +133,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(c.jVM, &env, nil)
defer C.DetachCurrentThread(c.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, c.jContext), "remoteEndpoint", fmt.Sprintf("()%s", util.StringSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, c.jContext), "remoteEndpoint", fmt.Sprintf("()%s", util.StringSign)))
// TODO(spetrovic): create a Java Endpoint interface.
epStr := util.GoString(env, C.CallContextStringMethod(env, c.jContext, mid))
ep, err := inaming.NewEndpoint(epStr)
diff --git a/runtimes/google/security/jni/jni.go b/runtimes/google/security/jni/jni.go
index 7f89560..2e50950 100644
--- a/runtimes/google/security/jni/jni.go
+++ b/runtimes/google/security/jni/jni.go
@@ -87,7 +87,7 @@
util.JThrowV(env, err)
return C.jobject(nil)
}
- cid := C.jmethodID(util.JMethodIDPtr(env, jECPublicKeyInfoClass, "<init>", fmt.Sprintf("([%s[%s[%s%s)%s", util.ByteSign, util.ByteSign, util.ByteSign, util.IntSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jECPublicKeyInfoClass, "<init>", fmt.Sprintf("([%s[%s[%s%s)%s", util.ByteSign, util.ByteSign, util.ByteSign, util.IntSign, util.VoidSign)))
return C.CallNewECPublicKeyInfoObject(env, jECPublicKeyInfoClass, cid, C.jbyteArray(util.JByteArrayPtr(env, key.X.Bytes())), C.jbyteArray(util.JByteArrayPtr(env, key.Y.Bytes())), C.jbyteArray(util.JByteArrayPtr(env, encoded)), C.jint(key.Params().BitSize))
}
@@ -109,9 +109,9 @@
jServiceCaveats := C.NewObjectArray(env, C.jsize(len(sCaveats)), jServiceCaveatClass, nil)
for i, sCaveat := range sCaveats {
util.GoRef(&sCaveat) // Un-refed when the Java Caveat object is finalized.
- cid := C.jmethodID(util.JMethodIDPtr(env, jCaveatImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jCaveatImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
jCaveat := C.CallNewCaveatObject(env, jCaveatImplClass, cid, C.jlong(util.PtrValue(&sCaveat)))
- scid := C.jmethodID(util.JMethodIDPtr(env, jServiceCaveatClass, "<init>", fmt.Sprintf("(%s%s)%s", util.StringSign, caveatSign, util.VoidSign)))
+ scid := C.jmethodID(util.JMethodIDPtrOrDie(env, jServiceCaveatClass, "<init>", fmt.Sprintf("(%s%s)%s", util.StringSign, caveatSign, util.VoidSign)))
jServiceCaveat := C.CallNewServiceCaveatObject(env, jServiceCaveatClass, scid, C.jstring(util.JStringPtr(env, string(sCaveat.Service))), jCaveat)
C.SetObjectArrayElement(env, jServiceCaveats, C.jsize(i), jServiceCaveat)
}
diff --git a/runtimes/google/security/jni/publicid.go b/runtimes/google/security/jni/publicid.go
index dd4e778..32af0b5 100644
--- a/runtimes/google/security/jni/publicid.go
+++ b/runtimes/google/security/jni/publicid.go
@@ -75,7 +75,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(id.jVM, &env, nil)
defer C.DetachCurrentThread(id.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, id.jPublicID), "names", fmt.Sprintf("()[%s", util.StringSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, id.jPublicID), "names", fmt.Sprintf("()[%s", util.StringSign)))
names := C.CallPublicIDNamesMethod(env, id.jPublicID, mid)
ret := make([]string, int(C.GetArrayLength(env, C.jarray(names))))
for i := 0; i < len(ret); i++ {
@@ -88,7 +88,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(id.jVM, &env, nil)
defer C.DetachCurrentThread(id.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, id.jPublicID), "match", fmt.Sprintf("(%s)%s", util.StringSign, util.BoolSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, id.jPublicID), "match", fmt.Sprintf("(%s)%s", util.StringSign, util.BoolSign)))
return C.CallPublicIDMatchMethod(env, id.jPublicID, mid, C.jstring(util.JStringPtr(env, string(pattern)))) == C.JNI_TRUE
}
@@ -96,7 +96,7 @@
var env *C.JNIEnv
C.AttachCurrentThread(id.jVM, &env, nil)
defer C.DetachCurrentThread(id.jVM)
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, id.jPublicID), "publicKey", fmt.Sprintf("()%s", util.ObjectSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, id.jPublicID), "publicKey", fmt.Sprintf("()%s", util.ObjectSign)))
jPublicKey := C.CallPublicIDPublicKeyMethod(env, id.jPublicID, mid)
return newPublicKey(env, jPublicKey)
}
@@ -108,9 +108,9 @@
util.GoRef(&context) // un-refed when the Java Context object is finalized.
contextSign := "Lcom/veyron2/security/Context;"
publicIDSign := "Lcom/veyron2/security/PublicID;"
- cid := C.jmethodID(util.JMethodIDPtr(env, jContextImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
+ cid := C.jmethodID(util.JMethodIDPtrOrDie(env, jContextImplClass, "<init>", fmt.Sprintf("(%s)%s", util.LongSign, util.VoidSign)))
jContext := C.CallPublicIDNewContextObject(env, jContextImplClass, cid, C.jlong(util.PtrValue(&context)))
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, id.jPublicID), "authorize", fmt.Sprintf("(%s)%s", contextSign, publicIDSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, id.jPublicID), "authorize", fmt.Sprintf("(%s)%s", contextSign, publicIDSign)))
jPublicID := C.CallPublicIDAuthorizeMethod(env, id.jPublicID, mid, jContext)
if err := util.JExceptionMsg(env); err != nil {
return nil, err
@@ -123,7 +123,7 @@
C.AttachCurrentThread(id.jVM, &env, nil)
defer C.DetachCurrentThread(id.jVM)
serviceCaveatSign := "Lcom/veyron2/security/ServiceCaveat;"
- mid := C.jmethodID(util.JMethodIDPtr(env, C.GetObjectClass(env, id.jPublicID), "thirdPartyCaveats", fmt.Sprintf("()[%s", serviceCaveatSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, C.GetObjectClass(env, id.jPublicID), "thirdPartyCaveats", fmt.Sprintf("()[%s", serviceCaveatSign)))
jServiceCaveats := C.CallPublicIDThirdPartyCaveatsMethod(env, id.jPublicID, mid)
length := int(C.GetArrayLength(env, C.jarray(jServiceCaveats)))
sCaveats := make([]security.ServiceCaveat, length)
@@ -140,7 +140,7 @@
func newPublicKey(env *C.JNIEnv, jPublicKey C.jobject) *ecdsa.PublicKey {
keySign := "Ljava/security/interfaces/ECPublicKey;"
keyInfoSign := "Lcom/veyron/runtimes/google/security/JNIPublicID$ECPublicKeyInfo;"
- mid := C.jmethodID(util.JMethodIDPtr(env, jPublicIDImplClass, "getKeyInfo", fmt.Sprintf("(%s)%s", keySign, keyInfoSign)))
+ mid := C.jmethodID(util.JMethodIDPtrOrDie(env, jPublicIDImplClass, "getKeyInfo", fmt.Sprintf("(%s)%s", keySign, keyInfoSign)))
jKeyInfo := C.CallPublicIDGetKeyInfoMethod(env, jPublicIDImplClass, mid, jPublicKey)
keyX := new(big.Int).SetBytes(util.JByteArrayField(env, jKeyInfo, "keyX"))
keyY := new(big.Int).SetBytes(util.JByteArrayField(env, jKeyInfo, "keyY"))
diff --git a/services/store/testutil/store.go b/services/store/testutil/store.go
index 50feb22..9190f09 100644
--- a/services/store/testutil/store.go
+++ b/services/store/testutil/store.go
@@ -7,6 +7,7 @@
"testing"
istore "veyron/services/store/server"
+ _ "veyron/services/store/typeregistryhack"
"veyron2/ipc"
"veyron2/naming"