commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r767483 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Descriptor.java java/org/apache/commons/runtime/Pointer.java native/shared/descriptor.c
Date Wed, 22 Apr 2009 12:23:34 GMT
Author: mturk
Date: Wed Apr 22 12:23:34 2009
New Revision: 767483

URL: http://svn.apache.org/viewvc?rev=767483&view=rev
Log:
Do not throw exceptions from finalize

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java
    commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java?rev=767483&r1=767482&r2=767483&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Descriptor.java
Wed Apr 22 12:23:34 2009
@@ -46,6 +46,9 @@
     private native void close0()
         throws IOException, InstantiationException;
 
+    private native void close1()
+        throws Throwable;
+
     private native void sync0()
         throws SyncFailedException, IOException, InstantiationException;
 
@@ -58,12 +61,7 @@
     protected final void finalize()
         throws Throwable
     {
-        try {
-            close0();
-        } catch (InstantiationException ex) {
-            // Class is alreay uninitialized.
-            // Ignore.
-        }
+        close1();
     }
 
     /**

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java?rev=767483&r1=767482&r2=767483&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Pointer.java Wed
Apr 22 12:23:34 2009
@@ -36,7 +36,8 @@
     private native void cleanup0()
         throws Throwable;
 
-    private native void cleanup1();
+    private native void cleanup1()
+        throws Throwable;
 
     /**
      * Size in bytes of the storage needed to represent the Pointer.

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c?rev=767483&r1=767482&r2=767483&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/descriptor.c Wed Apr 22 12:23:34
2009
@@ -107,7 +107,7 @@
 {
     if (_clazzn.i && J4MID(0000)) {
         acr_descriptor_callback_fn_t *callback;
-        jint  i  = GET_IFIELD_I(0000, _O);
+        jint   i = GET_IFIELD_I(0000, _O);
         jniptr p = GET_IFIELD_P(0001, _O);
         jniptr c = GET_IFIELD_P(0002, _O);
 
@@ -131,6 +131,28 @@
         ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINSTANCE, 0);
 }
 
+ACR_JNI_EXPORT_DECLARE(void, Descriptor, close1)(ACR_JNISTDARGS)
+{
+    if (_clazzn.i && J4MID(0000)) {
+        acr_descriptor_callback_fn_t *callback;
+        jint   i = GET_IFIELD_I(0000, _O);
+        jniptr p = GET_IFIELD_P(0001, _O);
+        jniptr c = GET_IFIELD_P(0002, _O);
+
+        if (p) {
+            SET_IFIELD_P(0001, _O, 0);
+        }
+        if (i >= 0) {
+            SET_IFIELD_I(0000, _O, -1);
+        }
+
+        callback = (acr_descriptor_callback_fn_t *)((acr_ptr_t)c);
+        if (callback) {
+            (*callback)(ACR_DESC_CLOSE, i, (void *)((acr_ptr_t)p));
+        }
+    }
+}
+
 ACR_JNI_EXPORT_DECLARE(void, Descriptor, sync0)(ACR_JNISTDARGS)
 {
     if (_clazzn.i && J4MID(0000)) {



Mime
View raw message