Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 57809 invoked from network); 22 Aug 2009 07:56:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 22 Aug 2009 07:56:34 -0000 Received: (qmail 69434 invoked by uid 500); 22 Aug 2009 07:56:56 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 69350 invoked by uid 500); 22 Aug 2009 07:56:55 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 69341 invoked by uid 99); 22 Aug 2009 07:56:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Aug 2009 07:56:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Aug 2009 07:56:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 843D423888E5; Sat, 22 Aug 2009 07:56:27 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r806805 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.msc.in include/acr_dso.h include/acr_error.h os/unix/dso.c shared/error.c test/testsuite.c Date: Sat, 22 Aug 2009 07:56:27 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090822075627.843D423888E5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Sat Aug 22 07:56:26 2009 New Revision: 806805 URL: http://svn.apache.org/viewvc?rev=806805&view=rev Log: Better error handling in dso Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c commons/sandbox/runtime/trunk/src/main/native/shared/error.c commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=806805&r1=806804&r2=806805&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original) +++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Sat Aug 22 07:56:26 2009 @@ -99,6 +99,7 @@ WINDOWS_OBJS= \ $(SRCDIR)/os/win32/dirent.$(OBJ) \ + $(SRCDIR)/os/win32/dso.$(OBJ) \ $(SRCDIR)/os/win32/env.$(OBJ) \ $(SRCDIR)/os/win32/execmem.$(OBJ) \ $(SRCDIR)/os/win32/file.$(OBJ) \ Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h?rev=806805&r1=806804&r2=806805&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr_dso.h Sat Aug 22 07:56:26 2009 @@ -54,7 +54,7 @@ * @param symname Name of the symbol to load. */ ACR_DECLARE(void *) ACR_DsoSym(JNIEnv *env, int dso, - const acr_pchar_t *symname); + const char *symname); #ifdef __cplusplus 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=806805&r1=806804&r2=806805&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 Sat Aug 22 07:56:26 2009 @@ -47,6 +47,7 @@ ACR_EX_EINSTANCE, /* java/lang/InstantiationException */ ACR_EX_EINTERNAL, /* java/lang/InternalError */ ACR_EX_ESECURITY, /* java/lang/SecurityException */ + ACR_EX_ULINK, /* java/lang/UnsatisfiedLinkError */ ACR_EX_ENOTIMPL, /* java/lang/UnsupportedOperationException */ ACR_EX_EIO, /* java/io/IOException */ ACR_EX_ESYNC, /* java/io/SyncFailedException */ Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c?rev=806805&r1=806804&r2=806805&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/dso.c Sat Aug 22 07:56:26 2009 @@ -66,21 +66,24 @@ ACR_DECLARE(int) ACR_DsoUnload(JNIEnv *_E, int dso) { - int rv; - - rv = acr_ioh_close(dso); + int rc; - ACR_THROW_IO_IF_ERR(rv); - return rv; + if (ACR_IOH_TYPE(dso) != ACR_DT_DSO) { + ACR_THROW_EX_IF_ERR(ACR_EX_EINVAL, ACR_EFTYPE); + return ACR_EINVAL; + } + rc = acr_ioh_close(dso); + ACR_THROW_IO_IF_ERR(rc); + return rc; } -ACR_DECLARE(void *) ACR_DsoSym(JNIEnv *_E, int dso, const acr_pchar_t *symname) +ACR_DECLARE(void *) ACR_DsoSym(JNIEnv *_E, int dso, const char *symname) { int rc; void *handle = ACR_IOH(dso); if (IS_INVALID_HANDLE(handle) || ACR_IOH_TYPE(dso) != ACR_DT_DSO) { - ACR_SET_OS_ERROR(ACR_EINVAL); + ACR_THROW_EX_IF_ERR(ACR_EX_EINVAL, ACR_EINVAL); return NULL; } else { @@ -88,7 +91,7 @@ if (retval == NULL) { rc = ACR_GET_OS_ERROR(); if (IS_VALID_HANDLE(_E)) { - ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_EIO, dlerror()); + ACR_ThrowExceptionA(_E, THROW_NMARK, ACR_EX_ULINK, dlerror()); } ACR_SET_OS_ERROR(rc); } 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=806805&r1=806804&r2=806805&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Sat Aug 22 07:56:26 2009 @@ -33,6 +33,7 @@ "java/lang/InstantiationException", "java/lang/InternalError", "java/lang/SecurityException", + "java/lang/UnsatisfiedLinkError", "java/lang/UnsupportedOperationException", "java/io/IOException", "java/io/SyncFailedException", @@ -155,7 +156,14 @@ static char *stuffunknown(char *buf, acr_size_t bufsize, int statcode) { - snprintf(buf, bufsize, "Unrecognized ACR error code %d", statcode); + switch (statcode) { + case ACR_EFTYPE: + strlcpy(buf, "Inappropriate file type or format", bufsize); + break; + default: + snprintf(buf, bufsize, "Unrecognized ACR error code %d", statcode); + break; + } return buf; } Modified: commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c?rev=806805&r1=806804&r2=806805&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/test/testsuite.c Sat Aug 22 07:56:26 2009 @@ -235,6 +235,17 @@ } +static int test_errno(int argc, const char *const argv[]) +{ + char buf[1024]; + + ACR_GetErrorString(ACR_EFTYPE, buf, sizeof(buf)); + fprintf(stdout, "ACR_EFTYPE : %s\n", buf); + + fprintf(stdout, "errno: OK\n"); + return 0; +} + int main(int argc, const char *const argv[]) { int rv = 0; @@ -291,6 +302,9 @@ else if (!strcasecmp(run_test, "jvm")) { rv = test_runjvm(argc, argv); } + else if (!strcasecmp(run_test, "error")) { + rv = test_errno(argc, argv); + } } cleanup: