commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1099052 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/Native.java native/shared/clazz.c native/shared/iofd.c native/shared/psockimpl.c
Date Tue, 03 May 2011 13:45:56 GMT
Author: mturk
Date: Tue May  3 13:45:55 2011
New Revision: 1099052

URL: http://svn.apache.org/viewvc?rev=1099052&view=rev
Log:
Add some JDK7 features

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
    commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
    commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c
    commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java?rev=1099052&r1=1099051&r2=1099052&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java Tue
May  3 13:45:55 2011
@@ -59,7 +59,8 @@ public final class Native
             try {
                 initialized = init0();
             } catch (Throwable t) {
-                // Ignore
+                if (HAS_MAINTAINER_MODE)
+                    t.printStackTrace();
             }
 
             if (!Platform.isSupported()) {

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=1099052&r1=1099051&r2=1099052&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Tue May  3 13:45:55 2011
@@ -296,6 +296,7 @@ AcrLoadClass(JNI_STDENV, JAVA_C_ID *claz
          */
 #if defined(DEBUG) || defined(_DEBUG)
         fprintf(stderr, "Cannot find %s\n", clazz->n);
+        fflush(stderr);
         (*env)->ExceptionDescribe(env);
 #endif
         goto failed;
@@ -314,6 +315,7 @@ AcrLoadClass(JNI_STDENV, JAVA_C_ID *claz
         if (c == 0) {
 #if defined(DEBUG) || defined(_DEBUG)
             fprintf(stderr, "Cannot find %s\n", an);
+            fflush(stderr);
             (*env)->ExceptionDescribe(env);
 #endif
             goto failed;

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c?rev=1099052&r1=1099051&r2=1099052&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c Tue May  3 13:45:55 2011
@@ -67,7 +67,10 @@ ACR_CLASS_CTOR(FileDescriptor)
     if (AcrLoadClass(env, &_clazzn, 0) == JNI_FALSE)
         return JNI_FALSE;
     J_LOAD_METHOD(0000);
-    J_LOAD_METHOD(0001);
+    /* FileDescriptor(int) is not present in jdk7
+     * windows implementation. Load as optional.
+     */
+    J_LOPT_METHOD(0001);
     J_LOAD_IFIELD(0000);
 #if defined(WINDOWS)
     J_LOAD_IFIELD(0001);
@@ -167,21 +170,32 @@ jobject
 AcrNewFileDescriptor(JNI_STDENV, int fd, void *fh)
 {
     jobject fo;
+    jint    rc = ACR_ENOMEM;
 
     if (!CLAZZ_LOADED) {
         return 0;
     }
-    fo = (*env)->NewObject(env, _clazzn.i, J4MID(0001), fd);
-#if defined (WINDOWS)
+    if (J4MID(0001) != 0)
+        fo = (*env)->NewObject(env, _clazzn.i, J4MID(0001), fd);
+    else
+        fo = (*env)->NewObject(env, _clazzn.i, J4MID(0000));
     if (fo != 0) {
-        if (AcrSetFileDescriptorHandle(env, fo, fh) != 0) {
+        if (J4MID(0001) != 0)
+            rc = AcrSetFileDescriptorFd(env, fo, fd);
+        else
+            rc = 0;
+#if defined (WINDOWS)
+        if (rc == 0)
+            rc = AcrSetFileDescriptorHandle(env, fo, fh);
+#endif
+    }
+    if (rc != 0) {
+        if (fo != 0) {
             (*env)->DeleteLocalRef(env, fo);
             fo = 0;
         }
+        ACR_SET_OS_ERROR(rc);
     }
-#endif
-    if (fo == 0)
-        ACR_SET_OS_ERROR(ACR_ENOMEM);
     return fo;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c?rev=1099052&r1=1099051&r2=1099052&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c Tue May  3 13:45:55 2011
@@ -40,14 +40,56 @@ J_DECLARE_F_ID(0000) = {
     "Ljava/io/FileDescriptor;"
 };
 
+J_DECLARE_F_ID(0001) = {
+    INVALID_FIELD_OFFSET,
+    INVALID_FIELD_OFFSET,
+    0,
+    "fd1",
+    "Ljava/io/FileDescriptor;"
+};
+
+static jclass TwoStacksPlainSocketImplClass = 0;
+
 ACR_CLASS_CTOR(SocketImpl)
 {
+    jclass tsc;
+
     if (AcrLoadClass(env, &_clazzn, 0) == JNI_FALSE)
         return JNI_FALSE;
     J_LOAD_IFIELD(0000);
     UNSAFE_IFIELD(0000);
-
     _clazzn.u = 1;
+#if defined(WINDOWS)
+    /* Try to load the TwoStacksPlainSocketImpl
+     */
+    tsc = (*env)->FindClass(env, "java/net/TwoStacksPlainSocketImpl");
+    if (tsc == 0 || IS_EXCEPTION_PENDING(env)) {
+        (*env)->ExceptionClear(env);
+        printf("TwoStacksPlainSocketImplClass not found %p\n", tsc);
+        fflush(stdout);
+        tsc = 0;
+    }
+    else {
+        _f0001n.i = (*env)->GetFieldID(env, tsc, _f0001n.n, _f0001n.s);
+        if (_f0001n.i == 0) {
+            (*env)->ExceptionClear(env);                            
+        }
+        else {
+            TwoStacksPlainSocketImplClass = (jclass)(*env)->NewGlobalRef(env, tsc);
+            (*env)->DeleteLocalRef(env, tsc);
+            if (TwoStacksPlainSocketImplClass == 0) {
+                (*env)->ExceptionClear(env);
+                /* Reference failed */
+                _f0001n.i = 0;
+            }
+            else {
+                _f0001n.o = AcrUnsafeObjectFieldIdOffset(env, TwoStacksPlainSocketImplClass,
_f0001n.i);                 
+                printf("TwoStacksPlainSocketImplClass loaded\n");
+                fflush(stdout);
+            }
+        }
+    }
+#endif
     return JNI_TRUE;
 }
 



Mime
View raw message