Error Fetching hashmap value from c++ using JNI from java


I have created a hashmap class which contains details of process name , id and its usage and using hashentry class I've stored values for each Table[i]. Problem is i'can access upto HASHMAP class cant go upto HASHENTRY error occurs.

My NATIVE code in CPlusPlus :


JNIEXPORT void JNICALL Java_newjni_JNITest_sayHello (JNIEnv*, jobject)
    HashMap hash;
    int x = hash.get(3);
    printf("%d", x);

 // ProcessInfo.h

 // In hashmapentry class
   HashEntry(int ke, int valu, string nam, int memusag, int cpuusag, double 
    diskusag, double netusag, string unam) {

    this->key = ke;

    this->value = valu;

    this->name = nam;

    this->memusage = memusag;

    this->cpuusage = cpuusag;

    this->diskusage = diskusag;

    this->netusage= netusag;

    this->uname= unam;

   //In hashMap class
     void put(int ke, int valu, string nam, int memusag, int cpuusag, double 
     diskusag, double netusag, string use) {

    int hash = ke;

    table[hash] = new HashEntry(ke, valu, nam, memusag, cpuusag, diskusag, 
    netusag, use);


  //used windows api to get values of process

   hash.put(i, (int)pid[i], pname, memusage, cpuusage[i], diskusage, netusage, 



 public class JNITest {  // Save as
 static {


 private native void sayHello();
 private native void print();

 public static void main(String[] args) {

    new JNITest().sayHello();  // Create an instance and invoke the native method

And the error occurs for me is :

# A fatal error has been detected by the Java Runtime Environment:
 #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffcf33417dd, pid=12584, tid=4912
# JRE version: 6.0_32-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (20.7-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [ProcessHash.dll+0x217dd]
# An error report file with more information is saved as:
# C:\Users\MrBean\Documents\NetBeansProjects\newJNI\hs_err_pid12584.log
# If you would like to submit a bug report, please visit:
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.


asked on Stack Overflow Jan 31, 2020 by NITHISH SIDDHARTHAN V • edited Feb 2, 2020 by Hovercraft Full Of Eels

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0