You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2006/07/19 09:47:04 UTC

svn commit: r423396 - in /incubator/harmony/enhanced/classlib/trunk/modules: archive/src/main/native/archive/shared/ luni/src/main/native/common/shared/ luni/src/main/native/include/linux/ luni/src/main/native/include/shared/ luni/src/main/native/inclu...

Author: hindessm
Date: Wed Jul 19 00:47:04 2006
New Revision: 423396

URL: http://svn.apache.org/viewvc?rev=423396&view=rev
Log:
Make exception code more like the awt version(s).

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/common/shared/exceptions.c
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/linux/jclprots.h
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/shared/exceptions.h
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h

Modified: incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c?rev=423396&r1=423395&r2=423396&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/archive/src/main/native/archive/shared/zip.c Wed Jul 19 00:47:04 2006
@@ -22,8 +22,6 @@
 void zfree PROTOTYPE ((void *opaque, void *address));
 void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
 
-void throwNewOutOfMemoryError (JNIEnv * env, char *message);
-
 /**
   * Throw java.lang.InternalError
   */

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/common/shared/exceptions.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/common/shared/exceptions.c?rev=423396&r1=423395&r2=423396&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/common/shared/exceptions.c (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/common/shared/exceptions.c Wed Jul 19 00:47:04 2006
@@ -16,41 +16,40 @@
 #include "exceptions.h"
 #include "jclglob.h"
 
-/**
-  * Throw java.io.IOException with the message provided
-  */
-void throwJavaIoIOException(JNIEnv *env, char *message)
+void throwNewExceptionByName(JNIEnv* env,
+                             const char* name, const char* message)
 {
-  jclass exceptionClass = (*env)->FindClass(env, "java/io/IOException");
-  if (0 == exceptionClass) { 
+  jclass exceptionClass = (*env)->FindClass(env, name);
+  if (exceptionClass == NULL) { 
     /* Just return if we can't load the exception class. */
     return;
   }
   (*env)->ThrowNew(env, exceptionClass, message);
+}  
+
+/**
+  * Throw java.io.IOException with the message provided
+  */
+void throwJavaIoIOException(JNIEnv* env, const char* message)
+{
+  throwNewExceptionByName(env, "java/io/IOException", message);
 }
 
 /**
   * Throw java.io.IOException with the "File closed" message
   * Consolidate all through here so message is consistent.
   */
-void
-throwJavaIoIOExceptionClosed (JNIEnv * env)
+void throwJavaIoIOExceptionClosed(JNIEnv* env)
 {
-  throwJavaIoIOException (env, "File closed");
+  throwJavaIoIOException(env, "File closed");
 }
 
 /**
   * Throw java.lang.IndexOutOfBoundsException
   */
-void
-throwIndexOutOfBoundsException (JNIEnv * env)
+void throwIndexOutOfBoundsException(JNIEnv* env)
 {
-  jclass exceptionClass = (*env)->FindClass(env, "java/lang/IndexOutOfBoundsException");
-  if (0 == exceptionClass) { 
-    /* Just return if we can't load the exception class. */
-    return;
-    }
-  (*env)->ThrowNew(env, exceptionClass, "");
+  throwNewExceptionByName(env, "java/lang/IndexOutOfBoundsException", "");
 }
 
 /**
@@ -59,27 +58,15 @@
   * with a VM function of that same name and this causes problems on
   * some platforms.
   */
-void
-throwNPException (JNIEnv * env, char *message)
+void throwNPException(JNIEnv* env, const char* message)
 {
-  jclass exceptionClass = (*env)->FindClass(env, "java/lang/NullPointerException");
-  if (0 == exceptionClass) { 
-    /* Just return if we can't load the exception class. */
-    return;
-    }
-  (*env)->ThrowNew(env, exceptionClass, message);
+  throwNewExceptionByName(env, "java/lang/NullPointerException", message);
 }
 
 /**
   * Throw java.lang.OutOfMemoryError
   */
-void
-throwNewOutOfMemoryError (JNIEnv * env, char *message)
+void throwNewOutOfMemoryError(JNIEnv* env, const char* message)
 {
-  jclass exceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
-  if (0 == exceptionClass) { 
-    /* Just return if we can't load the exception class. */
-    return;
-    }
-  (*env)->ThrowNew(env, exceptionClass, message);
+  throwNewExceptionByName(env, "java/lang/OutOfMemoryError", message);
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/linux/jclprots.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/linux/jclprots.h?rev=423396&r1=423395&r2=423396&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/linux/jclprots.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/linux/jclprots.h Wed Jul 19 00:47:04 2006
@@ -342,20 +342,22 @@
 
 /* NativesCommonIoHelpers*/
 void* getJavaIoFileDescriptorContentsAsPointer PROTOTYPE((JNIEnv *env, jobject fd));
-void throwNewOutOfMemoryError PROTOTYPE((JNIEnv * env, char * message));
+void throwNewExceptionByName PROTOTYPE((JNIEnv* env,
+                                        const char* name, const char* message));
+void throwNewOutOfMemoryError PROTOTYPE((JNIEnv* env, const char* message));
 jint ioh_readcharImpl PROTOTYPE((JNIEnv * env, jobject recv, IDATA descriptor));
-void throwJavaIoIOException PROTOTYPE((JNIEnv * env, char *message));
-void throwJavaIoIOExceptionClosed PROTOTYPE((JNIEnv * env));
+void throwJavaIoIOException PROTOTYPE((JNIEnv* env, const char* message));
+void throwJavaIoIOExceptionClosed PROTOTYPE((JNIEnv* env));
 void ioh_convertToPlatform PROTOTYPE((char *path));
 jint new_ioh_available PROTOTYPE((JNIEnv * env, jobject recv, jfieldID fdFID));
-void throwNPException PROTOTYPE((JNIEnv * env, char *message));
+void throwNPException PROTOTYPE((JNIEnv* env, const char* message));
 void setJavaIoFileDescriptorContentsAsPointer PROTOTYPE((JNIEnv * env, jobject fd, void *value));
 void ioh_writebytesImpl PROTOTYPE((JNIEnv * env, jobject recv, jbyteArray buffer, jint offset, jint count, IDATA descriptor));
 char* ioLookupErrorString PROTOTYPE((JNIEnv* env, I_32 anErrorNum));
 void ioh_writecharImpl PROTOTYPE((JNIEnv *env, jobject recv, jint c, IDATA descriptor));
 jint ioh_readbytesImpl PROTOTYPE((JNIEnv * env, jobject recv, jbyteArray buffer, jint offset, jint count, IDATA descriptor));
 void new_ioh_close PROTOTYPE((JNIEnv * env, jobject recv, jfieldID fdFID));
-void throwIndexOutOfBoundsException PROTOTYPE((JNIEnv * env));
+void throwIndexOutOfBoundsException PROTOTYPE((JNIEnv* env));
 
 /* NativesCommonSocket*/
 void throwSocketException PROTOTYPE((JNIEnv* env, I_32 errorNumber));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/shared/exceptions.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/shared/exceptions.h?rev=423396&r1=423395&r2=423396&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/shared/exceptions.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/shared/exceptions.h Wed Jul 19 00:47:04 2006
@@ -18,10 +18,12 @@
 
 #include <string.h>
 #include "vmi.h"
-void throwNewOutOfMemoryError(JNIEnv *env, char *message);
-void throwJavaIoIOException(JNIEnv *env, char *message);
-void throwJavaIoIOExceptionClosed(JNIEnv *env);
-void throwNPException(JNIEnv *env, char *message);
-void throwIndexOutOfBoundsException(JNIEnv *env);
+void throwNewExceptionByName(JNIEnv* env,
+                             const char* name, const char* message);
+void throwNewOutOfMemoryError(JNIEnv* env, const char* message);
+void throwJavaIoIOException(JNIEnv* env, const char* message);
+void throwJavaIoIOExceptionClosed(JNIEnv* env);
+void throwNPException(JNIEnv* env, const char* message);
+void throwIndexOutOfBoundsException(JNIEnv* env);
 
 #endif

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h?rev=423396&r1=423395&r2=423396&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/include/windows/jclprots.h Wed Jul 19 00:47:04 2006
@@ -606,15 +606,18 @@
   /* NativesCommonIoHelpers*/
   void *getJavaIoFileDescriptorContentsAsPointer
     PROTOTYPE ((JNIEnv * env, jobject fd));
-  void throwNewOutOfMemoryError PROTOTYPE ((JNIEnv * env, char *message));
+  void throwNewExceptionByName PROTOTYPE((JNIEnv* env,
+                                          const char* name,
+                                          const char* message));
+  void throwNewOutOfMemoryError PROTOTYPE ((JNIEnv* env, const char* message));
   jint ioh_readcharImpl
     PROTOTYPE ((JNIEnv * env, jobject recv, IDATA descriptor));
-  void throwJavaIoIOException PROTOTYPE ((JNIEnv * env, char *message));
-  void throwJavaIoIOExceptionClosed PROTOTYPE ((JNIEnv * env));
+  void throwJavaIoIOException PROTOTYPE ((JNIEnv* env, const char* message));
+  void throwJavaIoIOExceptionClosed PROTOTYPE ((JNIEnv* env));
   void ioh_convertToPlatform PROTOTYPE ((char *path));
   jint new_ioh_available
     PROTOTYPE ((JNIEnv * env, jobject recv, jfieldID fdFID));
-  void throwNPException PROTOTYPE ((JNIEnv * env, char *message));
+  void throwNPException PROTOTYPE ((JNIEnv* env, const char* message));
   void setJavaIoFileDescriptorContentsAsPointer
     PROTOTYPE ((JNIEnv * env, jobject fd, void *value));
   void ioh_writebytesImpl
@@ -627,7 +630,7 @@
     PROTOTYPE ((JNIEnv * env, jobject recv, jbyteArray buffer, jint offset,
                 jint count, IDATA descriptor));
   void new_ioh_close PROTOTYPE ((JNIEnv * env, jobject recv, jfieldID fdFID));
-  void throwIndexOutOfBoundsException PROTOTYPE ((JNIEnv * env));
+  void throwIndexOutOfBoundsException PROTOTYPE ((JNIEnv* env));
 
   /* NativesCommonSocket*/
   void throwSocketException PROTOTYPE ((JNIEnv * env, I_32 errorNumber));