Author: mturk Date: Sat Apr 25 13:05:55 2009 New Revision: 768523 URL: http://svn.apache.org/viewvc?rev=768523&view=rev Log: Add supported method
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.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=768523&r1=768522&r2=768523&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 Sat Apr 25 13:05:55 2009 @@ -16,6 +16,8 @@ package org.apache.commons.runtime; +import org.apache.commons.runtime.exception.*; + /** * Native library management. * @@ -48,6 +50,12 @@ throws Throwable { if (!initialized) { + if (!Platform.supported()) { + throw new UnsupportedOperatingSystemException( + "Apache Commons Runtime does not support this " + + "operating system" + ); + } initialized = init0(); } return initialized; Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java?rev=768523&r1=768522&r2=768523&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Platform.java Sat Apr 25 13:05:55 2009 @@ -30,6 +30,13 @@ // No class instance } + /** + * Check the platform validity. + * The caller should throw the {...@code UnsupportedOperatingSystemException} + * if this call returns {...@code false}. + */ + public static native boolean supported(); + /* * Get Platform integer property value. */ Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c?rev=768523&r1=768522&r2=768523&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/platform.c Sat Apr 25 13:05:55 2009 @@ -44,3 +44,12 @@ (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]); } + +ACR_JNI_EXPORT_DECLARE(jboolean, Platform, supported)(ACR_JNISTDARGS) +{ + UNREFERENCED_STDARGS; + + /* TODO: Find a minimum kernel version supported. + */ + return JNI_TRUE; +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c?rev=768523&r1=768522&r2=768523&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/platform.c Sat Apr 25 13:05:55 2009 @@ -44,3 +44,12 @@ (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]); } + +ACR_JNI_EXPORT_DECLARE(jboolean, Platform, supported)(ACR_JNISTDARGS) +{ + UNREFERENCED_STDARGS; + + /* TODO: Find a minimum kernel version supported. + */ + return JNI_TRUE; +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c?rev=768523&r1=768522&r2=768523&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/linux/platform.c Sat Apr 25 13:05:55 2009 @@ -44,3 +44,12 @@ (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]); } + +ACR_JNI_EXPORT_DECLARE(jboolean, Platform, supported)(ACR_JNISTDARGS) +{ + UNREFERENCED_STDARGS; + + /* TODO: Find a minimum kernel version supported. + */ + return JNI_TRUE; +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c?rev=768523&r1=768522&r2=768523&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/solaris/platform.c Sat Apr 25 13:05:55 2009 @@ -44,3 +44,12 @@ (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]); } + +ACR_JNI_EXPORT_DECLARE(jboolean, Platform, supported)(ACR_JNISTDARGS) +{ + UNREFERENCED_STDARGS; + + /* TODO: Find a minimum kernel version supported. + */ + return JNI_TRUE; +} Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=768523&r1=768522&r2=768523&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Sat Apr 25 13:05:55 2009 @@ -42,5 +42,17 @@ ia[6] = 248; ia[7] = 32760; - (*_E)->SetIntArrayRegion(_E, p, 0, 16, &ia[0]); + (*_E)->SetIntArrayRegion(_E, p, 0, 8, &ia[0]); +} + +ACR_JNI_EXPORT_DECLARE(jboolean, Platform, supported)(ACR_JNISTDARGS) +{ + UNREFERENCED_STDARGS; + if (acr_osver->dwMajorVersion < 5) + return JNI_FALSE; + if (acr_osver->dwMajorVersion == 5 && + acr_osver->dwMinorVersion < 1) + return JNI_FALSE; + + return JNI_TRUE; }