JDK-4093633 : (jni) Problems with DestroyJavaVM
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.1.4,5.0
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95,windows_nt,windows_xp
  • CPU: x86
  • Submitted: 1997-11-18
  • Updated: 2006-01-04
  • Resolved: 2006-01-04
Related Reports
Duplicate :  
Description
Name: joT67522			Date: 11/18/97


In a C program, I am using the following code:

/* Create and load a JVM */
jint create_jvm (JavaVM **p_vm, JNIEnv **p_env, JDK1_1InitArgs *vm_args, char *class_path) {
  jint err;
  vm_args->classpath = class_path;
  err = JNI_CreateJavaVM (p_vm, p_env, vm_args);
  return (err);
}

/* Destroy a JVM */

jint destroy_jvm (JavaVM **jvm) {
	jint err;
	err = (**jvm)->DestroyJavaVM (*jvm);
	return (err);
}

The creation procedure work well. I can then create instances of classes and manipulate them.
But the destroy_jvm returns always -1.

If this can help, I am using JDK 1.1.4 on win 95.
Needless to add that it is quite urgent for me to fix this problem. So I would really appreciate a fast but complete answer.

Thank you for your answer

-------------------------------------Also from a duplicate entry------------------------

jint destroy_jvm (JavaVM **jvm) {
        jint err;
        err = (**jvm)->DestroyJavaVM (*jvm);
        return (err);
}

It always returns -1. Do I use the function 'DestroyJavaVM' in a bad way?
This procedure is called with a JavaVM created successfully before and with which I an able to create 
and manipulate instances of the following class.

class test_java {

	test_java () {
		System.out.println ("Constructor called");
		str_attr = "Hello from Java";
		int_attr = 43;
		me = this;
		static_byte = 1;
		attr_class = new attr_class_test ();
	}


	public test_java me;
	
	public attr_class_test attr_class;

	public String str_attr;

	public void set_str_attr (String str) {
		str_attr = str;
	}

    // static field

    public static byte static_byte;

	//  <type> routines

	public int int_routine () {
		System.out.println ("Called int_routine");
		return (42);
	}

	public short short_routine () {
		System.out.println ("Called short_routine");
		return (43);
	}
	
	public char char_routine () {
		System.out.println ("Called char_routine");
		return 'f';
	}

	public boolean boolean_routine () {
		System.out.println ("Called boolean_routine");
		return false;
	}

	public void void_routine () { 
		System.out.println ("Called void_routine baby");
	}

	public float float_routine () {
		float f = (float)42.01; 
		System.out.println ("Called float_routine");
		return f;
	}

	public double double_routine () {
		double d = 4.200001;
		System.out.println ("Called double routine =  " + d );
		return d;
	}

	public double double_pass_routine (double d) {
		System.out.println("Called passer =  " + d);
		return d;			
	}

	public static char multi_arg_routine (double d, int i, String s, short t, char c) {
		System.out.println("a double = " + d + "\nan int " + i + "\na String" + s +
			 "\na short " + t + "\na char " + c + "\n That was fun...");
		return '?';
	}

	public static void print_array (char[] c) {
		int finish = c.length;
		System.out.println("In pary");
		for (int i = 0; i < finish; i++)
			System.out.print(c[i] +", ");
		System.out.println (";");
	}

	// end of <temp> routine stuff

	public int int_attr;

	public void set_int_attr (int newint) {
		int_attr = newint;
	}

	public void one_arg (String s) {
		System.out.println ("Received argument: " + s);
	}
	
	public void junk () {
		String s = "andcedef";
		System.out.println ("junk: String is: " + s);
	}


	public static void root () {
		System.out.println ("root routine called");
		test_java t = new test_java ();
		t.junk ();
	}

	public static void main (String argv[]) {
		System.out.println ("Started from command line");
		root ();
	}
}

The sooner I receive your answer, the better!

Best Regards

Guillaume Wong-So
(Review ID: 20363)
======================================================================

Comments
EVALUATION The original problem of DestroyJavaVM always returning -1 has been fixed since 1.2. There's also mention of DestroyJavaVM not properly cleaning up VM resources. While this situation has improved since 1.1 days, there is still room for further improvement. Since the specific problem in the description has been fixed, and the remaining cleanup issue is better captured in 6179880, I'm going to mark this as a duplicate of that bug.
04-01-2006

WORK AROUND Name: joT67522 Date: 11/18/97 ======================================================================
22-09-2004

EVALUATION DestroyJavaVM is not implemented in JDK 1.1. It simply waits for all user threads to terminate and returns an error code. This is documented in JNI documentation. Will lower its priority to 5. sheng.liang@Eng 1997-12-13 This bug has been closed as "Will Not Fix" due to a strategic redirection of resources to Java 1.4. If bug needs to be fixed in an old release then an escalation will need to be filed. At that time the JPSE will take this bug over. Bugs which are escalations from external customers will continue to be addressed by the support team. Internal customers may escalate bugs by filing them as priority 1 (P1) bugs. ###@###.### 2001-10-25
25-10-2001