C language code:
# include & lt; stdio.h>
#include
#include
# include "HelloNative. H"
//# define _XOPEN_SOURCE
Env JNIEXPORT jstring JNICALL Java_HelloNative_getPassword (JNIEnv *, jobject c1, jstring STR, jstring salt) {
Char * passwd;
Jstring out=0;
Passwd=crypt (" ABC ", "$6 $p840S0zS $");
If (passwd==NULL) {
Printf (" NULL ");
} else {
Printf (" password: % s \ n ", the passwd);
Out=(* env) - & gt; NewStringUTF (passwd, "utf-8");
}
Return the out;
}
An error is as follows:
[root @ test - 01 TMP] # Java HelloNative
#
# A fatal error has had been detected by the Java Runtime Environment:
#
# SIGSEGV=0 (0 xb) at PC x00007fc905af6acc, pid=61806, tid=0 x00007fc907036700
#
SE # JRE version: the Java (TM) Runtime Environment (8.0 _231 - b11) (build 1.8.0 comes with _231 - b11)
# Java VM: Java HotSpot (TM) 64 - Bit Server VM (25.231 - bl1 mixed mode Linux - amd64 compressed oops)
# Problematic frame:
# V [libjvm. So + 0 x6c5acc] jni_NewStringUTF + 0 x1c
#
# the Core dump written. The Default location:/TMP/Core or Core. 61806
#
# An error report file with more information is saved as:
#/TMP/hs_err_pid61806. Log
#
# If you order a like to submit a bug report, both please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside The Java Virtual Machine in native code.
# See problematic frame for the where to report the bug.
#
Aborted (core dumped)
CodePudding user response:
Here is the C/C + + plate, are you sure send Java problem here right?CodePudding user response:
Jni here can also, look from inside information, seems to be a string coding utf have a problemCodePudding user response: