Diff of /rvmroot/trunk/testing/tests/jni/src/AttachJVM.c [r12172] .. [r12173] Maximize Restore

  Switch to side-by-side view

--- a/rvmroot/trunk/testing/tests/jni/src/AttachJVM.c
+++ b/rvmroot/trunk/testing/tests/jni/src/AttachJVM.c
@@ -18,7 +18,7 @@
  * (page 90-91)
  */
 
-#include <pthread.h> 
+#include <pthread.h>
 #include <jni.h>
 JavaVM *jvm; /* The virtual machine instance */
 
@@ -59,7 +59,7 @@
 
   /****************************************************
    * Test AttachCurrentThread
-   * Pass NULL as the third argument 
+   * Pass NULL as the third argument
    */
   if (verbose_mode)
     printf("C thread %d: attaching to JVM, pid = %d\n", threadNum, pthread_self());
@@ -76,7 +76,7 @@
 
 
   /****************************************************
-   *  Now with a JNIEnv handle, try a few JNI functions 
+   *  Now with a JNIEnv handle, try a few JNI functions
    */
   cls = (*env)->FindClass(env, "myMain");
 
@@ -90,9 +90,9 @@
       printf("C thread %d: FindClass returns %d \n", threadNum, cls);
   }
 
-  dummyBreakpoint();  
-
-  mid = (*env)->GetStaticMethodID(env, cls, "compute", 
+  dummyBreakpoint();
+
+  mid = (*env)->GetStaticMethodID(env, cls, "compute",
                                   "([Ljava/lang/String;)I");
   if (mid == 0) {
     if (verbose_mode)
@@ -129,14 +129,14 @@
   }
 
   res = (*env)->CallStaticIntMethod(env, cls, mid, args);
-  
+
   if ((*env)->ExceptionOccurred(env)) {
     if (verbose_mode)
       (*env)->ExceptionDescribe(env);
     thread_pass = 0;
   } else if (res==123) {
     if (verbose_mode)
-      printf("C thread %d: Java call succeeds\n", threadNum);    
+      printf("C thread %d: Java call succeeds\n", threadNum);
   } else if (res==456) {
     if (verbose_mode)
       printf("C thread %d: ERROR, parameter fails to be passed to Java\n");
@@ -149,7 +149,7 @@
 
 
   /****************************************************
-   * test GetEnv 
+   * test GetEnv
    */
   res = (*jvm)->GetEnv(jvm, ((void *) &env2), JNI_VERSION_1_1);
   if (res < 0) {
@@ -166,7 +166,7 @@
       thread_pass = 0;
     }
   }
- 
+
 
   /****************************************************
    * Test DetachCurrentThread
@@ -249,7 +249,7 @@
     if (!strcmp(argv[1], "-verbose")) {
       verbose_mode = 1;
     }
-  } 
+  }
 
   if (res < 0) {
     fprintf(stderr, "FAIL: AttachJVM, cannot create Java VM from C\n");
@@ -278,7 +278,7 @@
   mid = (*env)->GetStaticMethodID(env, cls, "main",
                                   "([Ljava/lang/String;)V");
   if (mid == 0) {
-    if (verbose_mode) 
+    if (verbose_mode)
       printf("ERROR: GetStaticMethodID fails\n");
     main_pass = 0;
     goto destroy;
@@ -289,7 +289,7 @@
 
   jstr = (*env)->NewStringUTF(env, " main thread from C!");
   if (jstr == 0) {
-    if (verbose_mode) 
+    if (verbose_mode)
       printf("ERROR: NewStringUTF fails\n");
     main_pass = 0;
     goto destroy;
@@ -301,7 +301,7 @@
   stringClass = (*env)->FindClass(env, "java/lang/String");
   args = (*env)->NewObjectArray(env, 1, stringClass, jstr);
   if (args == 0) {
-    if (verbose_mode) 
+    if (verbose_mode)
       printf("ERROR: NewObjectArray fails\n");
     main_pass = 0;
     goto destroy;
@@ -318,35 +318,35 @@
       (*env)->ExceptionDescribe(env);
     }
     main_pass = 0;
-  } else { 
+  } else {
     if (verbose_mode)
       printf("CallStaticVoidMethod succeeds.\n");
   }
 
 
- 
-  /***************************************************
-   * Now create the threads and let them do some more Java work 
-   * pass the thread number to every thread 
-   */
-    
+
+  /***************************************************
+   * Now create the threads and let them do some more Java work
+   * pass the thread number to every thread
+   */
+
   pthread_create(&first_th,  NULL, thread_fun, (void *) 0);
-  pthread_create(&second_th, NULL, thread_fun, (void *) 1); 
-  
+  pthread_create(&second_th, NULL, thread_fun, (void *) 1);
+
   /* wait for the pthreads to finish */
   pthread_join(first_th, NULL);
   pthread_join(second_th, NULL);
-  
+
   /* sleep(60);  */
-  
-  
+
+
   if (verbose_mode)
     printf("C: threads are done, taking down JVM.\n");
-  
-  
-  
-  /***************************************************
-   *  Test GetCreatedJVMs 
+
+
+
+  /***************************************************
+   *  Test GetCreatedJVMs
    */
   numJVM = 0;
   jvmBuf = (JavaVM **) malloc(sizeof(JavaVM *) * BUFLEN);
@@ -369,17 +369,17 @@
         printf("AttachJVM: GetCreatedJavaVMs succeeds\n");
     }
   }
-  
-  
+
+
   /***************************************************
    *  Test DestroyJavaVM
    */
  destroy:
   rc = (*jvm)->DestroyJavaVM(jvm);
-  
+
   if (rc!=0) {
     if (verbose_mode)
-      printf("C: DestroyJavaVM returns with -1 as expected \n");    
+      printf("C: DestroyJavaVM returns with -1 as expected \n");
   } else {
     if (verbose_mode)
       printf("C: Unexpected return value from DestroyJavaVM\n");