I tried to run my java program and I am getting following error at my java console. Excuse me please for the long question, i am already sitting a week on this task from work, while I do not have any C++ experience.
I do not really understand, why this happens. Is it because of memory allocation? There were not any errors at compiling the dll's of it. Also, the method looks okay I guess?
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6c2f6dc7, pid=7588, tid=11168
#
# JRE version: Java(TM) SE Runtime Environment (8.0_91-b14) (build 1.8.0_91-b14)
# Java VM: Java HotSpot(TM) Client VM (25.91-b14 mixed mode, sharing windows-x86 )
# Problematic frame:
# V [jvm.dll+0x6dc7]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\sstankov\workspace\CalculatorAndHuman\hs_err_pid7588.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Here is the errorlog, which is generated by running the program.
--------------- T H R E A D ---------------
Current thread (0x02f0c400): JavaThread "main" [_thread_in_native, id=6812, stack(0x046e0000,0x04730000)]
siginfo: ExceptionCode=0xc0000005, writing address 0x0000017c
Registers:
EAX=0x02f0c540, EBX=0x00000000, ECX=0x0472f5a8, EDX=0x02f0c540
ESP=0x0472f638, EBP=0x0472f63c, ESI=0x00000000, EDI=0x02f0c400
EIP=0x6c2f6dc7, EFLAGS=0x00010246
Top of Stack: (sp=0x0472f638)
0x0472f638: 0472f6e8 0472f668 6c3c576d 00000000
0x0472f648: 00000006 02f0c400 16c31558 16c31558
0x0472f658: 02f0c400 02f0c858 6c5da232 00000003
0x0472f668: 0472f67c 069e1a09 0472f6e8 0472f778
0x0472f678: 0472f6e8 0472f6dc 069e129c 0472f778
0x0472f688: 6c425fff 16c31558 02f0c400 02f062e8
0x0472f698: 6c426037 02f06568 6c5c5804 047ebf78
0x0472f6a8: 0000000d 00000000 02f0c758 02f0cb44
Instructions: (pc=0x6c2f6dc7)
0x6c2f6da7: 45 10 89 86 7c 01 00 00 5e 5d c3 cc cc cc cc cc
0x6c2f6db7: cc cc cc cc cc cc cc cc cc 55 8b ec 56 8b 75 08
0x6c2f6dc7: c7 86 7c 01 00 00 05 00 00 00 a1 a8 3e 67 6c 8a
0x6c2f6dd7: 0d c1 36 67 6c 83 f8 01 75 04 84 c9 74 22 80 3d
Register to memory mapping:
EAX=0x02f0c540 is an unknown value
EBX=0x00000000 is an unknown value
ECX=0x0472f5a8 is pointing into the stack for thread: 0x02f0c400
EDX=0x02f0c540 is an unknown value
ESP=0x0472f638 is pointing into the stack for thread: 0x02f0c400
EBP=0x0472f63c is pointing into the stack for thread: 0x02f0c400
ESI=0x00000000 is an unknown value
EDI=0x02f0c400 is a thread
Stack: [0x046e0000,0x04730000], sp=0x0472f638, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x6dc7]
V [jvm.dll+0xd576d]
C [HumanWrapper.dll+0x1a09]
C [HumanWrapper.dll+0x129c]
C [HumanWrapper.dll+0x10f7]
j HumanController.gebeGehaltAus(LHumanBean;)V+0
j Controller.main([Ljava/lang/String;)V+53
v ~StubRoutines::call_stub
V [jvm.dll+0x1594e5]
V [jvm.dll+0x21f0ae]
V [jvm.dll+0x15957e]
V [jvm.dll+0xdb4f7]
V [jvm.dll+0xe3a8f]
C [javaw.exe+0x229a]
C [javaw.exe+0xaebf]
C [javaw.exe+0xaf49]
C [KERNEL32.DLL+0x18674]
C [ntdll.dll+0x65e17]
C [ntdll.dll+0x65de7]
C 0x00000000
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j HumanController.gebeGehaltAus(LHumanBean;)V+0
j Controller.main([Ljava/lang/String;)V+53
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x047ec400 JavaThread "Service Thread" daemon [_thread_blocked, id=14152, stack(0x17890000,0x178e0000)]
0x047bfc00 JavaThread "C1 CompilerThread0" daemon [_thread_blocked, id=14804, stack(0x17800000,0x17850000)]
0x047bec00 JavaThread "Attach Listener" daemon [_thread_blocked, id=740, stack(0x177b0000,0x17800000)]
0x047bcc00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1956, stack(0x17130000,0x17180000)]
0x047b3c00 JavaThread "Finalizer" daemon [_thread_blocked, id=12900, stack(0x16f80000,0x16fd0000)]
0x04756c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=9776, stack(0x16ef0000,0x16f40000)]
=>0x02f0c400 JavaThread "main" [_thread_in_native, id=6812, stack(0x046e0000,0x04730000)]
Other Threads:
0x04753000 VMThread [stack: 0x16e60000,0x16eb0000] [id=13988]
0x047fa000 WatcherThread [stack: 0x17920000,0x17970000] [id=13680]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap:
def new generation total 4928K, used 622K [0x06a00000, 0x06f50000, 0x0bf50000)
eden space 4416K, 14% used [0x06a00000, 0x06a9bba0, 0x06e50000)
from space 512K, 0% used [0x06e50000, 0x06e50000, 0x06ed0000)
to space 512K, 0% used [0x06ed0000, 0x06ed0000, 0x06f50000)
tenured generation total 10944K, used 0K [0x0bf50000, 0x0ca00000, 0x16a00000)
the space 10944K, 0% used [0x0bf50000, 0x0bf50000, 0x0bf50200, 0x0ca00000)
Metaspace used 51K, capacity 2246K, committed 2368K, reserved 4480K
Card table byte_map: [0x068b0000,0x06940000] byte_map_base: 0x0687b000
Polling page: 0x02ee0000
CodeCache: size=32768Kb used=694Kb max_used=694Kb free=32073Kb
bounds [0x04830000, 0x048e0000, 0x06830000]
total_blobs=161 nmethods=23 adapters=70
compilation: enabled
Compilation events (10 events):
Event: 0.081 Thread 0x047bfc00 19 java.lang.StringBuilder::append (8 bytes)
Event: 0.081 Thread 0x047bfc00 nmethod 19 0x048da2c8 code [0x048da3d0, 0x048da4bc]
Event: 0.081 Thread 0x047bfc00 20 ! sun.net.www.ParseUtil::decode (316 bytes)
Event: 0.084 Thread 0x047bfc00 nmethod 20 0x048da608 code [0x048da8b0, 0x048db5c8]
Event: 0.084 Thread 0x047bfc00 21 java.io.WinNTFileSystem::normalize (143 bytes)
Event: 0.084 Thread 0x047bfc00 nmethod 21 0x048dc988 code [0x048dcad0, 0x048dcd4c]
Event: 0.086 Thread 0x047bfc00 22 java.lang.Math::min (11 bytes)
Event: 0.086 Thread 0x047bfc00 nmethod 22 0x048dd008 code [0x048dd100, 0x048dd170]
Event: 0.093 Thread 0x047bfc00 23 java.lang.String::indexOf (166 bytes)
Event: 0.093 Thread 0x047bfc00 nmethod 23 0x048dd1c8 code [0x048dd2e0, 0x048dd510]
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Internal exceptions (2 events):
Event: 0.041 Thread 0x02f0c400 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class; name or signature does not match> (0x06a079d8) thrown at [C:\re\workspace\8-2-build-windows-i586-cygwin\jdk8u91\6644\hotspot\src\share\v)4núÕ¤?
Event: 0.041 Thread 0x02f0c400 Exception <a 'java/lang/NoSuchMethodError': Method sun.misc.Unsafe.prefetchRead(Ljava/lang/Object;J)V name or signature does not match> (0x06a07ca8) thrown at [C:\re\workspace\8-2-build-windows-i586-cygwin\jdk8u91\6644\hotspot\src\share\vm\prims\jni.cpp, l
Events (10 events):
Event: 0.071 loading class sun/nio/cs/ThreadLocalCoders$2
Event: 0.071 loading class sun/nio/cs/ThreadLocalCoders$2 done
Event: 0.082 loading class sun/misc/URLClassPath$FileLoader$1
Event: 0.082 loading class sun/misc/URLClassPath$FileLoader$1 done
Event: 0.087 loading class CalculatorController
Event: 0.087 loading class CalculatorController done
Event: 0.093 loading class HumanBean
Event: 0.093 loading class HumanBean done
Event: 0.093 loading class HumanController
Event: 0.093 loading class HumanController done
Dynamic libraries:
0x00320000 - 0x00353000 C:\Program Files (x86)\Java\jre1.8.0_91\bin\javaw.exe
0x77b70000 - 0x77cfc000 C:\WINDOWS\SYSTEM32\ntdll.dll
0x752c0000 - 0x75390000 C:\WINDOWS\System32\KERNEL32.DLL
0x77800000 - 0x779d8000 C:\WINDOWS\System32\KERNELBASE.dll
0x75780000 - 0x757f8000 C:\WINDOWS\System32\ADVAPI32.dll
0x751a0000 - 0x7525d000 C:\WINDOWS\System32\msvcrt.dll
0x74760000 - 0x747a3000 C:\WINDOWS\System32\sechost.dll
0x74600000 - 0x746be000 C:\WINDOWS\System32\RPCRT4.dll
0x74590000 - 0x745b0000 C:\WINDOWS\System32\SspiCli.dll
0x74580000 - 0x7458a000 C:\WINDOWS\System32\CRYPTBASE.dll
0x75260000 - 0x752b6000 C:\WINDOWS\System32\bcryptPrimitives.dll
0x74bf0000 - 0x74d65000 C:\WINDOWS\System32\USER32.dll
0x776b0000 - 0x776c6000 C:\WINDOWS\System32\win32u.dll
0x74d70000 - 0x74d92000 C:\WINDOWS\System32\GDI32.dll
0x74da0000 - 0x74eff000 C:\WINDOWS\System32\gdi32full.dll
0x77630000 - 0x776ac000 C:\WINDOWS\System32\msvcp_win.dll
0x776d0000 - 0x777e6000 C:\WINDOWS\System32\ucrtbase.dll
0x70270000 - 0x70481000 C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.16299.1268_none_573b93e96ee39a52\COMCTL32.dll
0x75390000 - 0x755d5000 C:\WINDOWS\System32\combase.dll
0x75cf0000 - 0x75d15000 C:\WINDOWS\System32\IMM32.DLL
0x780e0000 - 0x7819f000 C:\Program Files (x86)\Java\jre1.8.0_91\bin\msvcr100.dll
0x6c2f0000 - 0x6c6ba000 C:\Program Files (x86)\Java\jre1.8.0_91\bin\client\jvm.dll
0x75c50000 - 0x75c56000 C:\WINDOWS\System32\PSAPI.DLL
0x74560000 - 0x74568000 C:\WINDOWS\SYSTEM32\VERSION.dll
0x70240000 - 0x70264000 C:\WINDOWS\SYSTEM32\WINMM.dll
0x72d90000 - 0x72d98000 C:\WINDOWS\SYSTEM32\WSOCK32.dll
0x74b80000 - 0x74be6000 C:\WINDOWS\System32\WS2_32.dll
0x70210000 - 0x70233000 C:\WINDOWS\SYSTEM32\winmmbase.dll
0x75730000 - 0x75768000 C:\WINDOWS\System32\cfgmgr32.dll
0x6b4e0000 - 0x6b4ec000 C:\Program Files (x86)\Java\jre1.8.0_91\bin\verify.dll
0x6ce80000 - 0x6cea1000 C:\Program Files (x86)\Java\jre1.8.0_91\bin\java.dll
0x6b320000 - 0x6b333000 C:\Program Files (x86)\Java\jre1.8.0_91\bin\zip.dll
0x75d20000 - 0x77054000 C:\WINDOWS\System32\SHELL32.dll
0x74af0000 - 0x74b78000 C:\WINDOWS\System32\shcore.dll
0x77060000 - 0x77624000 C:\WINDOWS\System32\windows.storage.dll
0x756e0000 - 0x75725000 C:\WINDOWS\System32\shlwapi.dll
0x75670000 - 0x7567e000 C:\WINDOWS\System32\kernel.appcore.dll
0x745b0000 - 0x745f5000 C:\WINDOWS\System32\powrprof.dll
0x75c30000 - 0x75c44000 C:\WINDOWS\System32\profapi.dll
0x17b70000 - 0x17ba9000 C:\Users\sstankov\workspace\CalculatorAndHuman\src\CalculatorV2.dll
0x59910000 - 0x59925000 C:\Users\sstankov\workspace\CalculatorAndHuman\src\CalculatorWrapper.dll
0x17bb0000 - 0x17be9000 C:\Users\sstankov\workspace\CalculatorAndHuman\src\Human.dll
0x069e0000 - 0x069f6000 C:\Users\sstankov\workspace\CalculatorAndHuman\src\HumanWrapper.dll
0x17bf0000 - 0x17d71000 C:\WINDOWS\SYSTEM32\dbghelp.dll
VM Arguments:
jvm_args: -Djava.library.path=C:\Users\sstankov\workspace\CalculatorAndHuman\src -Dfile.encoding=Cp1252
java_command: Controller
java_class_path (initial): C:\Program Files (x86)\Java\jre1.8.0_91\lib\resources.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\rt.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\jsse.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\jce.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\charsets.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\jfr.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\access-bridge-32.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\cldrdata.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\dnsns.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\jaccess.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\jfxrt.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\localedata.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\nashorn.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\sunec.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\sunjce_provider.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\sunmscapi.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\sunpkcs11.jar;C:\Program Files (x86)\Java\jre1.8.0_91\lib\ext\zipfs.jar;C:\Users\sstankov\workspace\CalculatorAndHuman\bin
Launcher Type: SUN_STANDARD
Environment Variables:
PATH=C:/Program Files (x86)/Java/jre1.8.0_91/bin/client;C:/Program Files (x86)/Java/jre1.8.0_91/bin;C:/Program Files (x86)/Java/jre1.8.0_91/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Enterprise Vault\EVClient\;C:\Program Files (x86)\Sennheiser\SoftphoneSDK\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Users\sstankov\Downloads\jdk-12.0.2\bin;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\Hostx64\x64;C:\Users\sstankov\Downloads\SWIG\swigwin-4.0.0;C:\Users\sstankov\AppData\Local\Microsoft\WindowsApps;C:\Users\sstankov\Downloads\jdk-12.0.2\bin;;C:\WINDOWS\system32;
USERNAME=sstankov
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 78 Stepping 3, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 10.0 , 64 bit Build 16299 (10.0.16299.1146)
CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 78 stepping 3, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, rtm, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx
Memory: 4k page, physical 8257640k(2493824k free), swap 14549096k(5016488k free)
vm_info: Java HotSpot(TM) Client VM (25.91-b14) for windows-x86 JRE (1.8.0_91-b14), built on Apr 1 2016 01:01:28 by "java_re" with MS VC++ 10.0 (VS2010)
time: Thu Aug 22 15:09:08 2019
elapsed time: 0 seconds (0d 0h 0m 0s)
Here is my native CPP-File
#pragma comment(lib, "Human.lib")
#include "HumanHeader.h"
#include "HumanController.h"
#include <iostream>
Human createHuman(JNIEnv env, jclass clsx, jobject javaObject) {
jclass cls = (env).GetObjectClass(javaObject);
jfieldID fidInt1 = (env).GetFieldID(cls, "alter", "I");
jint alter = (env).GetIntField(javaObject, fidInt1);
jfieldID fidInt2 = (env).GetFieldID(cls, "gehalt", "I");
jint gehaltInt = (env).GetIntField(javaObject, fidInt2);
jfieldID fidInt3 = (env).GetFieldID(cls, "gehaltDouble", "D");
jdouble gehaltDouble = (env).GetDoubleField(javaObject, fidInt3);
jfieldID fidName = (env).GetFieldID(cls, "name", "Ljava/lang/String;");
jstring nameString = (jstring)(env).GetObjectField(cls, fidName);
jboolean isCopy;
const char* convertedValue = (env).GetStringUTFChars(nameString, &isCopy);
std::string stringName = std::string(convertedValue);
Human newHuman = Human::erstelleHumanExport(alter, stringName, gehaltDouble, gehaltInt);
return newHuman;
}
/*
* Class: HumanController
* Method: triggerGeburtstag
* Signature: (LHumanBean;)V
*/
JNIEXPORT void JNICALL Java_HumanController_triggerGeburtstag(JNIEnv *env, jclass cls, jobject javaObject) {
Human humanBeanMirror = createHuman(*env, cls, javaObject);
Human::triggerGeburtstagExport(humanBeanMirror);
}
Header of the "3rd Party DLL"
#pragma once
#include <iostream>
using namespace std;
class Human
{
public:
int alter;
string name;
bool volljaehrig;
double gehaltsDouble;
int gehaltInt;
Human(int x, string y, double z, int g);
// funktion mit dllExport
static __declspec(dllexport) void triggerGeburtstagExport(Human human);
static __declspec(dllexport) bool isVolljaehrigExport(Human human);
static __declspec(dllexport) void gebeGehaltAusExport(Human human);
static __declspec(dllexport) Human erstelleHumanExport(int alter, string name, double gehaltsDouble, int gehaltInt);
};
3rd Party CPP File
#include "HumanHeader.h"
#include <iostream>
Human::Human(int x, string y, double z, int g) {
alter = x;
name = y;
gehaltsDouble = z;
gehaltInt = g;
}
void Human::gebeGehaltAusExport(Human h) {
cout << "Gehalt Int = " << h.gehaltInt << endl;
cout << "Gehalt Double = " << h.gehaltsDouble << endl;
}
Human Human::erstelleHumanExport(int alter, string name, double gehaltDouble, int gehaltInt) {
return Human(alter, name, gehaltDouble, gehaltInt);
}
bool Human::isVolljaehrigExport(Human h) {
if (h.alter >= 18) {
cout << h.name << " ist bereits Volljährig! Alter = " << h.alter << endl;
return true;
}
else {
cout << h.name << " ist nicht Volljährig!!!! Alter = " << h.alter << endl;
return true;
}
}
void Human::triggerGeburtstagExport(Human h) {
h.alter++;
cout << h.name << " ist nun " << h.alter << " Jahre alt" << endl;
}
And lastly, my java file:
public class Controller {
public static void main(String[] args) {
System.out.println("library: "
+ System.getProperty("java.library.path"));
//CalculatorController calcController = new CalculatorController();
HumanBean human = new HumanBean("John Doe", 16, 3000, 2988.77);
HumanController.gebeGehaltAus(human);
boolean isVollJaehrig = HumanController.isVolljaehrig(human);
System.out.println("Is 18 years or older?? " + isVollJaehrig);
HumanController.triggerGeburtstag(human);
HumanController.triggerGeburtstag(human);
HumanController.isVolljaehrig(human);
System.out.println("Is 18 years or older?" + isVollJaehrig);
System.out.println("Test finished!");
// TODO Auto-generated method stub
}
}
EDIT:
HumanController.java
public class HumanController {
public static native void triggerGeburtstag(HumanBean human);
public static native boolean isVolljaehrig(HumanBean human);
public static native void gebeGehaltAus(HumanBean human);
public static native HumanBean erstelleHuman();
static {
System.loadLibrary("Human");
System.loadLibrary("HumanWrapper");
}
}
/*
* Class: HumanController
* Method: gebeGehaltAus
* Signature: (LHumanBean;)V
*/
JNIEXPORT void JNICALL Java_HumanController_gebeGehaltAus(JNIEnv *env, jclass cls, jobject javaObject) {
Human humanBeanMirror = createHuman(*env, cls, javaObject);
Human::gebeGehaltAusExport(humanBeanMirror);
}
Java Bean Human
public class HumanBean {
String name;
int alter;
int gehalt;
double gehaltDouble;
public HumanBean(String name, int alter, int gehalt, double gehaltDouble) {
super();
this.name = name;
this.alter = alter;
this.gehalt = gehalt;
this.gehaltDouble = gehaltDouble;
}
User contributions licensed under CC BY-SA 3.0