JDK-4343727 : JNI FindClass Crashes VM
  • Type: Bug
  • Component: vm-legacy
  • Sub-Component: jvmpi
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_nt
  • CPU: x86
  • Submitted: 2000-06-06
  • Updated: 2002-08-28
  • Resolved: 2002-08-28
Related Reports
Relates :  

Name: skT45625			Date: 06/06/2000

java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

I have a C++ JVMPI profiling agent that worked fine with all JDK 1.2.x
versions. After having downloaded JDK 1.3.0, the profiling agent crashes
the VM on Windows NT 4.0. The crash is due to an illegal memory access
("The memory could not be 'read'") inside a FindClass function call as
shown in the code snippet below:

// the following function in the profiling agent is called by JVMPI
// in response to the JVMPI_INIT_DONE event
void JVMPI_EVENT_INIT_DONE_handler(JNIEnv* jniInterface)
  jclass threadClass = jniInterface->FindClass("java/lang/Thread");
  if (threadClass == NULL)
    cout << "ERROR: Class java/lang/Thread Not Found." << endl;
  jclass configurationClass = jniInterface->FindClass("Configuration");
  if (configurationClass == NULL)
    cout << "ERROR: Class Configuration Not Found." << endl;
  // end of code snippet

The first FindClass call works fine but the second one crashes the VM.
In fact, if I replace "Configuration" with any class in the Java standard
API (e.g., "java/net/Socket" or "java/lang/Throwable"), the second FindClass
call will also succeed. I went further and replaced "Configuration" with
a class that DOES NOT exist (e.g., "onfiguration"), and the call to FindClass
did what I expected: it returned without crashing and gave the NULL value.
If I replace "Configuration" with any other class that I wrote and that is
not in the Java standard API, the FindClass call again crashes the VM.
(Review ID: 105805) 
After some experimentation, I have
found out more about this problem that I have with FindClass. It turns out
that not only FindClass with any of my classes as the parameter crashes 
the VM but the VM also crashes when its *class loader* tries to load any
of my classes. If I comment out the FindClass in my code snippet below
the profiling agent starts up correctly but when the VM tries to load
my Java class that contains the main() method it crashes with an illegal
memory access. The main method never begins execution and when I
turn on the -verbose option I can see that the VM tries to load the Java
class with the main() method but crashes at that time. In conclusion,
if a JVMPI agent is loaded via -XrunMyProfiler: then the JVM will crash
whenever it tries to load a user class. I tend to believe it's a JVM bug
because all this worked fine with all the JDK 1.2.x versions.

Reinhard  2000-06-07

EVALUATION Name: dd4877 Date: 05/31/2002 daniel.daugherty@Sun 2002-05-31 This bug was updated almost a year ago indicating that we could not reproduce this failure. I'm planning on closing this bug as "not reproducible" within one week if I don't hear anything further. ======================================================================

WORK AROUND Name: skT45625 Date: 06/06/2000 I haven't found a workaround yet. ======================================================================