Esempio n. 1
0
func (i *invoker) Signature(ctx *context.T, call rpc.ServerCall) ([]signature.Interface, error) {
	env, freeFunc := jutil.GetEnv()
	jContext, err := jcontext.JavaContext(env, ctx, nil)
	if err != nil {
		freeFunc()
		return nil, err
	}
	// This method will invoke the freeFunc().
	jInterfaces, err := jutil.CallFutureMethod(env, freeFunc, i.jInvoker, "getSignature", []jutil.Sign{contextSign}, jContext)
	if err != nil {
		return nil, err
	}
	env, freeFunc = jutil.GetEnv()
	defer freeFunc()
	defer jutil.DeleteGlobalRef(env, jInterfaces)
	interfacesArr, err := jutil.GoObjectArray(env, jInterfaces)
	if err != nil {
		return nil, err
	}
	result := make([]signature.Interface, len(interfacesArr))
	for i, jInterface := range interfacesArr {
		err = jutil.GoVomCopy(env, jInterface, jInterfaceClass, &result[i])
		if err != nil {
			return nil, err
		}
	}
	return result, nil
}
Esempio n. 2
0
// GoBlessingsArray converts the provided Java Blessings array into a Go
// Blessings slice.
func GoBlessingsArray(env jutil.Env, jBlessingsArr jutil.Object) ([]security.Blessings, error) {
	barr, err := jutil.GoObjectArray(env, jBlessingsArr)
	if err != nil {
		return nil, err
	}
	ret := make([]security.Blessings, len(barr))
	for i, jBlessings := range barr {
		var err error
		if ret[i], err = GoBlessings(env, jBlessings); err != nil {
			return nil, err
		}
	}
	return ret, nil
}
Esempio n. 3
0
// GoCaveats converts the provided Java Caveat array into a Go Caveat slice.
func GoCaveats(env jutil.Env, jCaveats jutil.Object) ([]security.Caveat, error) {
	cavArr, err := jutil.GoObjectArray(env, jCaveats)
	if err != nil {
		return nil, err
	}
	ret := make([]security.Caveat, len(cavArr))
	for i, jCav := range cavArr {
		var err error
		if ret[i], err = GoCaveat(env, jCav); err != nil {
			return nil, err
		}
	}
	return ret, nil
}
Esempio n. 4
0
// GoNetworkAddressArray converts a Java array of NetworkAddress objects into a
// Go slice of net.Addr values.
func GoNetworkAddressArray(env jutil.Env, jAddrs jutil.Object) ([]net.Addr, error) {
	arr, err := jutil.GoObjectArray(env, jAddrs)
	if err != nil {
		return nil, err
	}
	ret := make([]net.Addr, len(arr))
	for i, jAddr := range arr {
		var err error
		if ret[i], err = GoNetworkAddress(env, jAddr); err != nil {
			return nil, err
		}
	}
	return ret, nil
}
Esempio n. 5
0
//export Java_io_v_v23_security_BlessingStoreImpl_nativeClearDischarges
func Java_io_v_v23_security_BlessingStoreImpl_nativeClearDischarges(jenv *C.JNIEnv, jBlessingStoreImpl C.jobject, goRef C.jlong, jDischarges C.jobject) {
	env := jutil.Env(uintptr(unsafe.Pointer(jenv)))
	blessingStore := *(*security.BlessingStore)(jutil.GoRefValue(jutil.Ref(goRef)))
	arr, err := jutil.GoObjectArray(env, jutil.Object(uintptr(unsafe.Pointer(jDischarges))))
	if err != nil {
		jutil.JThrowV(env, err)
		return
	}
	var discharges []security.Discharge
	for _, jDischarge := range arr {
		discharge, err := GoDischarge(env, jDischarge)
		if err != nil {
			jutil.JThrowV(env, err)
			return
		}
		discharges = append(discharges, discharge)
	}
	blessingStore.ClearDischarges(discharges...)
}
Esempio n. 6
0
// GoListenAddrs converts Java ListenSpec$Address array into a Go
// rpc.ListenAddrs value.
func GoListenAddrs(env jutil.Env, jAddrs jutil.Object) (rpc.ListenAddrs, error) {
	addrarr, err := jutil.GoObjectArray(env, jAddrs)
	if err != nil {
		return nil, err
	}
	addrs := make(rpc.ListenAddrs, len(addrarr))
	for i, jAddr := range addrarr {
		var err error
		addrs[i].Protocol, err = jutil.CallStringMethod(env, jAddr, "getProtocol", nil)
		if err != nil {
			return nil, err
		}
		addrs[i].Address, err = jutil.CallStringMethod(env, jAddr, "getAddress", nil)
		if err != nil {
			return nil, err
		}
	}
	return addrs, nil
}