commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1091838 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/exception/ native/include/acr/ native/os/unix/ native/shared/
Date Wed, 13 Apr 2011 16:07:00 GMT
Author: mturk
Date: Wed Apr 13 16:07:00 2011
New Revision: 1091838

URL: http://svn.apache.org/viewvc?rev=1091838&view=rev
Log:
Rename system exception class

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/SystemException.java
      - copied, changed from r1084131, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java
Removed:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java
Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixSemaphore.java
    commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixSemaphore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixSemaphore.java?rev=1091838&r1=1091837&r2=1091838&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixSemaphore.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/PosixSemaphore.java
Wed Apr 13 16:07:00 2011
@@ -16,6 +16,9 @@
 package org.apache.commons.runtime;
 
 import java.io.IOException;
+import org.apache.commons.runtime.exception.AlreadyExistsException;
+import org.apache.commons.runtime.exception.NoSuchObjectException;
+import org.apache.commons.runtime.exception.SystemException;
 
 /**
  * PosixSemaphore class.
@@ -32,4 +35,24 @@ final class PosixSemaphore extends Semap
         // No Instance
     }
 
+    private static native int  unlink0(String name);
+    private static native long create0(String name, int value)
+        throws IllegalAccessException,
+               IllegalArgumentException,
+               AlreadyExistsException,
+               SystemException;
+    private static native long open0(String name)
+        throws IllegalAccessException,
+               IllegalArgumentException,
+               NoSuchObjectException,
+               SystemException;
+    
+    private static native int  close0(long sema);
+    private static native int  wait0(long sema);
+    private static native int  try0(long sema);
+    private static native int  release0(long sema);
+
+    // OS semaphore handle (sem_t)
+    private long sd;
+
 }

Copied: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/SystemException.java
(from r1084131, commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java)
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/SystemException.java?p2=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/SystemException.java&p1=commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java&r1=1084131&r2=1091838&rev=1091838&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/OperatingSystemException.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/exception/SystemException.java
Wed Apr 13 16:07:00 2011
@@ -17,21 +17,21 @@
 package org.apache.commons.runtime.exception;
 
 /**
- * OperatingSystemException
+ * SystemException
  *
  * @author Mladen Turk
  *
  */
 
-public class OperatingSystemException extends RuntimeException
+public class SystemException extends RuntimeException
 {
 
-    public OperatingSystemException()
+    public SystemException()
     {
         super();
     }
 
-    public OperatingSystemException(String msg)
+    public SystemException(String msg)
     {
         super(msg);
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h?rev=1091838&r1=1091837&r2=1091838&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h Wed Apr 13 16:07:00
2011
@@ -58,7 +58,7 @@ enum {
     ACR_EX_ESOCK,           /* java/net/SocketException */
     ACR_EX_EEXIST,          /* exception/AlreadyExistsException */
     ACR_EX_ENOENT,          /* exception/NoSuchObjectException */
-    ACR_EX_OSERR,           /* exception/OperatingSystemException */
+    ACR_EX_ESYS,            /* exception/SystemException */
     ACR_EX_ETIMEOUT,        /* exception/TimeoutException */
     ACR_EX_UNSUPPORTED,     /* exception/UnsupportedOperatingSystemException */
     ACR_EX_LEN
@@ -1606,9 +1606,11 @@ ACR_INLINE(DWORD) AcrNetOsError()
 #if defined(DEBUG) || defined(_DEBUG)
 #define ACR_THROW(CL, ER)       AcrDebugThrowException(env, __FILE_FUNC_LINE__, (CL), (ER))
 #define ACR_THROW_OS_ERROR(CL)  AcrDebugThrowException(env, __FILE_FUNC_LINE__, (CL), ACR_GET_OS_ERROR())
+#define ACR_THROW_SYS_ERROR()   AcrDebugThrowException(env, __FILE_FUNC_LINE__, ACR_EX_ESYS,
ACR_GET_OS_ERROR())
 #else
 #define ACR_THROW(CL, ER)       AcrThrowException(env, (CL), (ER))
 #define ACR_THROW_OS_ERROR(CL)  AcrThrowException(env, (CL), ACR_GET_OS_ERROR())
+#define ACR_THROW_SYS_ERROR()   AcrThrowException(env, ACR_EX_ESYS, ACR_GET_OS_ERROR())
 #endif
 #define ACR_THROW_MSG(CL, MS)   AcrThrow(env, (CL), MS)
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c?rev=1091838&r1=1091837&r2=1091838&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/semaphore.c Wed Apr 13 16:07:00
2011
@@ -69,11 +69,14 @@ ACR_JNI_EXPORT(jobject, Semaphore, getIm
     return (*env)->NewObject(env, _clazzn.i, J4MID(0000));
 }
 
-ACR_JNI_EXPORT(void, PosixSemaphore, unlink0)(JNI_STDARGS, jstring name)
+ACR_JNI_EXPORT(jint, PosixSemaphore, unlink0)(JNI_STDARGS, jstring name)
 {
+    int rc = 0;
     WITH_CSTR(name) {
-        sem_unlink(J2S(name));        
-    } DONE_WITH_STR(name);    
+        if (sem_unlink(J2S(name)) == -1)
+            rc = ACR_GET_OS_ERROR();
+    } DONE_WITH_STR(name);
+    return rc;
 }
 
 ACR_JNI_EXPORT(jlong, PosixSemaphore, create0)(JNI_STDARGS,
@@ -94,7 +97,7 @@ ACR_JNI_EXPORT(jlong, PosixSemaphore, cr
                 ACR_THROW(ACR_EX_EACCES, 0);
             }
             else {
-                ACR_THROW_OS_ERROR(ACR_EX_EIO);                
+                ACR_THROW_SYS_ERROR();                
             }
         }
     } DONE_WITH_STR(name);    
@@ -120,24 +123,22 @@ ACR_JNI_EXPORT(jlong, PosixSemaphore, op
                 ACR_THROW(ACR_EX_EACCES, 0);
             }
             else {
-                ACR_THROW_OS_ERROR(ACR_EX_EIO);                
+                ACR_THROW_SYS_ERROR();                
             }
-            ACR_THROW_OS_ERROR(ACR_EX_EIO);                
         }
     } DONE_WITH_STR(name);    
     
     return P2J(sp);
 }
 
-ACR_JNI_EXPORT(void, PosixSemaphore, close0)(JNI_STDARGS, jlong sem)
+ACR_JNI_EXPORT(jint, PosixSemaphore, close0)(JNI_STDARGS, jlong sem)
 {
     sem_t *sp = J2P(sem, sem_t *);
 
-    if (sp != SEM_FAILED) {
-        if (sem_close(sp)) {
-            ACR_THROW_OS_ERROR(ACR_EX_OSERR);
-        }
-    }
+    if (sem_close(sp) == -1)
+        return ACR_GET_OS_ERROR();
+    else
+        return 0;
 }
 
 ACR_JNI_EXPORT(jint, PosixSemaphore, wait0)(JNI_STDARGS, jlong sem)

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=1091838&r1=1091837&r2=1091838&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Wed Apr 13 16:07:00 2011
@@ -52,7 +52,7 @@ static struct {
     { 0, "java/net/SocketException"                             },
     { 0, ACR_EXCEPTION_CP "AlreadyExistsException"              },    
     { 0, ACR_EXCEPTION_CP "NoSuchObjectException"               },
-    { 0, ACR_EXCEPTION_CP "OperatingSystemException"            },
+    { 0, ACR_EXCEPTION_CP "SystemException"                     },
     { 0, ACR_EXCEPTION_CP "TimeoutException"                    },
     { 0, ACR_EXCEPTION_CP "UnsupportedOperatingSystemException" },
     { 0, 0                                                      }



Mime
View raw message