You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/24 19:54:28 UTC
svn commit: r768384 - in /commons/sandbox/runtime/trunk/src:
main/java/org/apache/commons/runtime/io/Status.java
main/native/shared/error.c test/org/apache/commons/runtime/TestAll.java
test/org/apache/commons/runtime/TestStatus.java
Author: mturk
Date: Fri Apr 24 17:54:28 2009
New Revision: 768384
URL: http://svn.apache.org/viewvc?rev=768384&view=rev
Log:
Add Status class
Added:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java (with props)
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStatus.java (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/shared/error.c
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java?rev=768384&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java Fri Apr 24 17:54:28 2009
@@ -0,0 +1,253 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime.io;
+
+/**
+ * IO Status codes.
+ *
+ * @since Runtime 1.0
+ *
+ */
+public class Status {
+
+ private Status()
+ {
+ // No class instance
+ }
+
+ /*
+ * Get Platform dependent error codes.
+ */
+ private static native int[] initerr0();
+
+ static {
+ int [] i = initerr0();
+ EACCES = i[1];
+ EEXIST = i[2];
+ ENAMETOOLONG = i[3];
+ ENOENT = i[4];
+ ENOTDIR = i[5];
+ ENOSPC = i[6];
+ ENOMEM = i[7];
+ EMFILE = i[8];
+ ENFILE = i[9];
+ EBADF = i[10];
+ EINVAL = i[11];
+ ESPIPE = i[12];
+ EAGAIN = i[13];
+ EINTR = i[14];
+ ENOTSOCK = i[15];
+ ECONNREFUSED = i[16];
+ EINPROGRESS = i[17];
+ ECONNABORTED = i[18];
+ ECONNRESET = i[19];
+ EHOSTUNREACH = i[20];
+ ENETUNREACH = i[21];
+ EFTYPE = i[22];
+ EPIPE = i[23];
+ EXDEV = i[24];
+ ENOTEMPTY = i[25];
+ EAFNOSUPPORT = i[26];
+
+ }
+
+ /* ACR CANONICAL ERROR VALUES */
+ /** @see IS_EACCES */
+ public static final int EACCES;
+
+ /** @see IS_EEXIST */
+ public static final int EEXIST;
+ /** @see IS_ENAMETOOLONG */
+ public static final int ENAMETOOLONG;
+ /** @see IS_ENOENT */
+ public static final int ENOENT;
+ /** @see IS_ENOTDIR */
+ public static final int ENOTDIR;
+ /** @see IS_ENOSPC */
+ public static final int ENOSPC;
+ /** @see IS_ENOMEM */
+ public static final int ENOMEM;
+ /** @see IS_EMFILE */
+ public static final int EMFILE;
+ /** @see IS_ENFILE */
+ public static final int ENFILE;
+ /** @see IS_EBADF */
+ public static final int EBADF;
+ /** @see IS_EINVAL */
+ public static final int EINVAL;
+
+ /** @see IS_ESPIPE */
+ public static final int ESPIPE;
+ /**
+ * @see IS_EAGAIN.
+ * Use STATUS_IS_EAGAIN instead of just testing this value
+ */
+ public static final int EAGAIN;
+ /** @see IS_EINTR */
+ public static final int EINTR;
+ /** @see IS_ENOTSOCK */
+ public static final int ENOTSOCK;
+
+ /** @see IS_ECONNREFUSED */
+ public static final int ECONNREFUSED;
+
+ /** @see IS_EINPROGRESS */
+ public static final int EINPROGRESS;
+ /**
+ * @see IS_ECONNABORTED
+ * Use ACR_STATUS_IS_ECONNABORTED instead of just testing this value
+ */
+ public static final int ECONNABORTED;
+ /** @see IS_ECONNRESET */
+ public static final int ECONNRESET;
+ /** @see IS_EHOSTUNREACH */
+ public static final int EHOSTUNREACH;
+ /** @see IS_ENETUNREACH */
+ public static final int ENETUNREACH;
+ /** @see IS_EFTYPE */
+ public static final int EFTYPE;
+ /** @see IS_EPIPE */
+ public static final int EPIPE;
+ /** @see IS_EXDEV */
+ public static final int EXDEV;
+ /** @see IS_ENOTEMPTY */
+ public static final int ENOTEMPTY;
+ /** @see IS_EAFNOSUPPORT */
+ public static final int EAFNOSUPPORT;
+
+
+ private static final int OS_START_ERROR = 20000;
+ private static final int OS_START_STATUS = 70000;
+ private static final int UTIL_START_STATUS = 100000;
+ private static final int OS_START_USERERR = 120000;
+ private static final int OS_START_CANONERR = 620000;
+ private static final int OS_START_EAIERR = 670000;
+ private static final int OS_START_SYSERR = 720000;
+ private static final int OS_ERRSPACE_SIZE = 50000;
+
+ /** Unable to perform a stat on the file. */
+ public static final int ENOSTAT = OS_START_ERROR + 1;
+ /** Pool from which to allocate the memory was not provided. */
+ public static final int ENOPOOL = OS_START_ERROR + 2;
+ /* empty slot: +3 */
+ /** Date is invalid */
+ public static final int EBADDATE = OS_START_ERROR + 4;
+ /** Socket is invalid */
+ public static final int EINVALSOCK = OS_START_ERROR + 5;
+ /** Invalid process structure */
+ public static final int ENOPROC = OS_START_ERROR + 6;
+ /** Invalid time structure */
+ public static final int ENOTIME = OS_START_ERROR + 7;
+ /** Invalid directory structure */
+ public static final int ENODIR = OS_START_ERROR + 8;
+ /** Invalid lock structure */
+ public static final int ENOLOCK = OS_START_ERROR + 9;
+ /** Invalid poll structure */
+ public static final int ENOPOLL = OS_START_ERROR + 10;
+ /** Given data is not a socket */
+ public static final int ENOSOCKET = OS_START_ERROR + 11;
+ /** Given data is not a thread */
+ public static final int ENOTHREAD = OS_START_ERROR + 12;
+ /** Given data is not a thread key */
+ public static final int ENOTHDKEY = OS_START_ERROR + 13;
+ /* General failure <em>specific information not available</em>. */
+ public static final int EGENERAL = OS_START_ERROR + 14;
+ /** The specified IP address is invalid */
+ public static final int EBADIP = OS_START_ERROR + 15;
+ /** The specified netmask is invalid */
+ public static final int EBADMASK = OS_START_ERROR + 16;
+ /** No more shared memory available */
+ public static final int ENOSHMAVAIL = OS_START_ERROR + 17;
+ /** Unable to open the {@code dso} object. */
+ /* empty slot: +18 */
+ public static final int EDSOOPEN = OS_START_ERROR + 19;
+ /** Could not find the requested symbol */
+ public static final int ESYMNOTFOUND = OS_START_ERROR + 26;
+ /** Not enough entropy to continue */
+ public static final int ENOTENOUGHENTROPY = OS_START_ERROR + 28;
+
+ /* ACR private errors added to the std APR errors */
+ public static final int EISNULL = OS_START_ERROR + 100;
+ public static final int EINVALSIZ = OS_START_ERROR + 101;
+ public static final int ERANGE = OS_START_ERROR + 102;
+ public static final int ECLASSNOTFOUND = OS_START_ERROR + 103;
+
+
+ /** @see ACR_STATUS_IS_INCHILD */
+ public static final int INCHILD = OS_START_STATUS + 1;
+ /** @see ACR_STATUS_IS_INPARENT */
+ public static final int INPARENT = OS_START_STATUS + 2;
+ /** @see ACR_STATUS_IS_DETACH */
+ public static final int DETACH = OS_START_STATUS + 3;
+ /** @see ACR_STATUS_IS_NOTDETACH */
+ public static final int NOTDETACH = OS_START_STATUS + 4;
+ /** @see ACR_STATUS_IS_CHILD_DONE */
+ public static final int CHILD_DONE = OS_START_STATUS + 5;
+ /** @see ACR_STATUS_IS_CHILD_NOTDONE */
+ public static final int CHILD_NOTDONE = OS_START_STATUS + 6;
+ /** @see ACR_STATUS_IS_TIMEUP */
+ public static final int TIMEUP = OS_START_STATUS + 7;
+ /** @see ACR_STATUS_IS_INCOMPLETE */
+ public static final int INCOMPLETE = OS_START_STATUS + 8;
+ /* empty slot: +9 */
+ /* empty slot: +10 */
+ /* empty slot: +11 */
+ /** @see ACR_STATUS_IS_BADCH */
+ public static final int BADCH = OS_START_STATUS + 12;
+ /** @see ACR_STATUS_IS_BADARG */
+ public static final int BADARG = OS_START_STATUS + 13;
+ /** @see ACR_STATUS_IS_EOF */
+ public static final int EOF = OS_START_STATUS + 14;
+ /** @see ACR_STATUS_IS_NOTFOUND */
+ public static final int NOTFOUND = OS_START_STATUS + 15;
+ /* empty slot: +16 */
+ /* empty slot: +17 */
+ /* empty slot: +18 */
+ /** @see ACR_STATUS_IS_ANONYMOUS */
+ public static final int ANONYMOUS = OS_START_STATUS + 19;
+ /** @see ACR_STATUS_IS_FILEBASED */
+ public static final int FILEBASED = OS_START_STATUS + 20;
+ /** @see ACR_STATUS_IS_KEYBASED */
+ public static final int KEYBASED = OS_START_STATUS + 21;
+ /** @see ACR_STATUS_IS_EINIT */
+ public static final int EINIT = OS_START_STATUS + 22;
+ /** @see ACR_STATUS_IS_ENOTIMPL */
+ public static final int ENOTIMPL = OS_START_STATUS + 23;
+ /** @see ACR_STATUS_IS_EMISMATCH */
+ public static final int EMISMATCH = OS_START_STATUS + 24;
+ /** @see ACR_STATUS_IS_EBUSY */
+ public static final int EBUSY = OS_START_STATUS + 25;
+
+ /** Native system error */
+ public static boolean IS_NATIVE_ERROR(int s)
+ {
+ return (s < OS_START_ERROR);
+ }
+
+ /** Cannonical system error */
+ public static boolean IS_OS_SYSERR(int s)
+ {
+ return ((s > OS_START_SYSERR) &&
+ (s < OS_START_SYSERR + OS_ERRSPACE_SIZE));
+ }
+
+ public static boolean IS_STATUS(int s)
+ {
+ return ((s > OS_START_STATUS) && (s < OS_START_STATUS + 1000));
+ }
+
+}
Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/Status.java
------------------------------------------------------------------------------
svn:eol-style = native
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=768384&r1=768383&r2=768384&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Fri Apr 24 17:54:28 2009
@@ -468,3 +468,44 @@
}
}
}
+
+ACR_JNI_EXPORT_DECLARE(jintArray, io_Status, initerr0)(ACR_JNISTDARGS)
+{
+ jintArray ra;
+ int i[32];
+ UNREFERENCED_O;
+
+ i[0] = 0;
+ i[1] = ACR_EACCES;
+ i[2] = ACR_EEXIST;
+ i[3] = ACR_ENAMETOOLONG;
+ i[4] = ACR_ENOENT;
+ i[5] = ACR_ENOTDIR;
+ i[6] = ACR_ENOSPC;
+ i[7] = ACR_ENOMEM;
+ i[8] = ACR_EMFILE;
+ i[9] = ACR_ENFILE;
+ i[10] = ACR_EBADF;
+ i[11] = ACR_EINVAL;
+ i[12] = ACR_ESPIPE;
+ i[13] = ACR_EAGAIN;
+ i[14] = ACR_EINTR;
+ i[15] = ACR_ENOTSOCK;
+ i[16] = ACR_ECONNREFUSED;
+ i[17] = ACR_EINPROGRESS;
+ i[18] = ACR_ECONNABORTED;
+ i[19] = ACR_ECONNRESET;
+ i[20] = ACR_EHOSTUNREACH;
+ i[21] = ACR_ENETUNREACH;
+ i[22] = ACR_EFTYPE;
+ i[23] = ACR_EPIPE;
+ i[24] = ACR_EXDEV;
+ i[25] = ACR_ENOTEMPTY;
+ i[26] = ACR_EAFNOSUPPORT;
+
+ ra = (*_E)->NewIntArray(_E, 32);
+ if (ra) {
+ (*_E)->SetIntArrayRegion(_E, ra, 0, 32, i);
+ }
+ return ra;
+}
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java?rev=768384&r1=768383&r2=768384&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestAll.java Fri Apr 24 17:54:28 2009
@@ -35,6 +35,7 @@
suite.addTest(TestProperties.suite());
suite.addTest(TestOS.suite());
suite.addTest(TestUUID.suite());
+ suite.addTest(TestStatus.suite());
suite.addTest(TestMemory.suite());
suite.addTest(TestDirectByteBuffer.suite());
suite.addTest(TestPrivate.suite());
Added: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStatus.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStatus.java?rev=768384&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStatus.java (added)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStatus.java Fri Apr 24 17:54:28 2009
@@ -0,0 +1,62 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.runtime;
+
+import org.apache.commons.runtime.io.Status;
+import java.lang.System;
+import junit.framework.*;
+
+/**
+ * Status Test.
+ *
+ */
+public class TestStatus extends TestCase
+{
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(TestStatus.class);
+ return suite;
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ System.loadLibrary("acr");
+ }
+
+ public void testStatus()
+ throws Exception
+ {
+ int err = Status.EACCES;
+ assertTrue("Status", err != 0);
+ }
+
+ public void testStatusSys()
+ throws Exception
+ {
+ int err = 720000 + 32;
+ assertTrue("Status", Status.IS_OS_SYSERR(err));
+ }
+
+ public void testStatusStat()
+ throws Exception
+ {
+ int err = Status.EOF;
+ assertTrue("Status", Status.IS_STATUS(err));
+ }
+
+}
Propchange: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestStatus.java
------------------------------------------------------------------------------
svn:eol-style = native