JNA。 char* 不包含结果

JNA. char* It does not contain the result

我有带外部 C 方法的 dll:

extern "C" {
  int ADAPTERSHARED_EXPORT full_hash(unsigned char* data,
    uint64_t size,
    int algorithm,
    char* result,
    int *res_size
   );
}

从java一个调用这个方法 界面

public interface CA extends Library {
        CA INSTANCE = (CA) Native.loadLibrary(
                (Platform.isWindows() ? "HashAdapterC" : "libHAL"), CA.class);
        int full_hash(byte[] data, long size, int algorithm, String result, IntByReference res_size);
}

和主要方法

public static void main(String[] args) {
        logger.debug("being started");
        try {
            CA lib = CA.INSTANCE;
            String str = "1234567";
            String res = "";
            IntByReference in = new IntByReference(32);
            byte[] data = str.getBytes();
            int i = lib.full_hash(data, str.length(), 3, res, in);
            logger.debug("result = " + res);
            logger.debug("error = " + i);
            return;
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("err");
            return;
        }
    }

调用后结果为空字符串

如果从 C

调用它
 unsigned char data[] = {
            0xB1, 0x94, 0xBA, 0xC8, 0x0A, 0x08, 0xF5, 0x3B,
            0x36, 0x6D, 0x00, 0x8E, 0x58
        };
        uint64_t size = sizeof(data);
    int res_size = 32;
    char* result = (char*)malloc(res_size);
    int is_success = hash(data, size, 3, result, &res_size);
    if (is_success == 0)
    {
        printf("Success\n");
        int i;
        for (i = 0; i < res_size; ++i)
        {
            printf("%X", (unsigned char)result[i]);
        }
        printf("\n");
    }

我得到结果字符串。

不是 char* - 字符串吗?还是我会使用不同的类型?

必须将结果声明为 byte[]

public interface CA extends Library {
    CA INSTANCE = (CA) Native.loadLibrary(
            (Platform.isWindows() ? "HashAdapterC" : "libHAL"), CA.class);
    int full_hash(byte[] data, long size, int algorithm, byte[] result, IntByReference res_size);
}