Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JVM Crash within native method

Shitij Agarwal
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a simple Java file that calls a native method implemented in a .cpp file. From within the native method, I wish to get the value of a Java static field (just a hypothetical situation I'm using for my testing purposes). In order to do that, I need to find the Java class within my native method. When I use GetObjectClass, it seems to find the class, but does not find the field or method that I wish to access. When I use FindClass, it doesn't seem to find the class itself. I did some research on it, and found that this problem may be because my jvm.dll in the jre/bin/client directory may not be loaded. Is this true? Why would my FindClass fail if I have my .java, .class, and .cpp files all in the same folder?

Next, I tried to use LoadLibrary(<path to jvm.dll> from within my native method in order to load the jvm.dll file before looking for the java class using FindClass, but when I include the LoadLibrary call in my code and execute the Java program, I get the javaw.exe crash dialog box.

Could anybody please tell me why I'm not being able to tell me why my FindClass is failing, and if the reason is that jvm.dll is not loaded, how/where can I load it?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic