bind: fix generated JNI name for Go packages with underscores

Fixes golang/go#27669

Change-Id: Id4071e14fe2a35b2b54801af9d0161f08f3e9e9c
Reviewed-on: https://go-review.googlesource.com/135755
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
Elias Naur 2018-09-17 19:06:20 +02:00
parent 3409effab8
commit 756a47a9b9
2 changed files with 7 additions and 7 deletions

View File

@ -735,14 +735,14 @@ func (g *JavaGen) genJNIFuncSignature(o *types.Func, sName string, jm *java.Func
g.Printf("Java_%s_", g.jniPkgName())
if sName != "" {
if proxy {
g.Printf(g.className())
g.Printf(java.JNIMangle(g.className()))
// 0024 is the mangled form of $, for naming inner classes.
g.Printf("_00024proxy%s", sName)
} else {
g.Printf(java.JNIMangle(g.javaTypeName(sName)))
}
} else {
g.Printf(g.className())
g.Printf(java.JNIMangle(g.className()))
}
g.Printf("_")
if jm != nil {
@ -1091,7 +1091,7 @@ func (g *JavaGen) genJNIVar(o *types.Var) {
n := java.JNIMangle(g.javaTypeName(o.Name()))
// setter
g.Printf("JNIEXPORT void JNICALL\n")
g.Printf("Java_%s_%s_set%s(JNIEnv *env, jclass clazz, %s v) {\n", g.jniPkgName(), g.className(), n, g.jniType(o.Type()))
g.Printf("Java_%s_%s_set%s(JNIEnv *env, jclass clazz, %s v) {\n", g.jniPkgName(), java.JNIMangle(g.className()), n, g.jniType(o.Type()))
g.Indent()
g.genJavaToC("v", o.Type(), modeRetained)
g.Printf("var_set%s_%s(_v);\n", g.pkgPrefix, o.Name())
@ -1101,7 +1101,7 @@ func (g *JavaGen) genJNIVar(o *types.Var) {
// getter
g.Printf("JNIEXPORT %s JNICALL\n", g.jniType(o.Type()))
g.Printf("Java_%s_%s_get%s(JNIEnv *env, jclass clazz) {\n", g.jniPkgName(), g.className(), n)
g.Printf("Java_%s_%s_get%s(JNIEnv *env, jclass clazz) {\n", g.jniPkgName(), java.JNIMangle(g.className()), n)
g.Indent()
g.Printf("%s r0 = ", g.cgoType(o.Type()))
g.Printf("var_get%s_%s();\n", g.pkgPrefix, o.Name())

View File

@ -21,7 +21,7 @@ Java_underscore_1pkg_Underscore_1pkg__1init(JNIEnv *env, jclass _unused) {
}
JNIEXPORT void JNICALL
Java_underscore_1pkg_Underscore_pkg_underscore_1func(JNIEnv* env, jclass _clazz) {
Java_underscore_1pkg_Underscore_1pkg_underscore_1func(JNIEnv* env, jclass _clazz) {
proxyunderscore_pkg__Underscore_func();
}
@ -46,13 +46,13 @@ Java_underscore_1pkg_Underscore_1struct_getUnderscore_1field(JNIEnv *env, jobjec
}
JNIEXPORT void JNICALL
Java_underscore_1pkg_Underscore_pkg_setUnderscore_1var(JNIEnv *env, jclass clazz, jlong v) {
Java_underscore_1pkg_Underscore_1pkg_setUnderscore_1var(JNIEnv *env, jclass clazz, jlong v) {
nint _v = (nint)v;
var_setunderscore_pkg_Underscore_var(_v);
}
JNIEXPORT jlong JNICALL
Java_underscore_1pkg_Underscore_pkg_getUnderscore_1var(JNIEnv *env, jclass clazz) {
Java_underscore_1pkg_Underscore_1pkg_getUnderscore_1var(JNIEnv *env, jclass clazz) {
nint r0 = var_getunderscore_pkg_Underscore_var();
jlong _r0 = (jlong)r0;
return _r0;