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 2011/04/11 19:07:49 UTC
svn commit: r1091129 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/Os.java
java/org/apache/commons/runtime/util/UUID.java native/os/linux/os.c
native/shared/native.c native/shared/uuid.c
Author: mturk
Date: Mon Apr 11 17:07:49 2011
New Revision: 1091129
URL: http://svn.apache.org/viewvc?rev=1091129&view=rev
Log:
Do not use cryptic native wrappers
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Os.java
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java
commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c
commons/sandbox/runtime/trunk/src/main/native/shared/native.c
commons/sandbox/runtime/trunk/src/main/native/shared/uuid.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Os.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Os.java?rev=1091129&r1=1091128&r2=1091129&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Os.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Os.java Mon Apr 11 17:07:49 2011
@@ -41,57 +41,37 @@ public final class Os
* @param type OS type to test.
*/
private static native int init();
- private static native int get0();
- private static native int get1();
- private static native String get2();
- private static native String get3();
- private static native String get4();
- private static native String get5();
+ private static native int getType();
static {
if (init() != 0) {
// Cannot happen (tm)
}
- TYPE = OsType.valueOf(get0());
+ TYPE = OsType.valueOf(getType());
}
/**
* Name of the operating system implementation.
*/
- public static String getSysname()
- {
- return get2();
- }
+ public static native String getSysname();
/**
* Network name of this machine.
*/
- public static String getNodename()
- {
- return get3();
- }
+ public static native String getNodename();
/**
* Release level of the operating system.
*/
- public static String getRelease()
- {
- return get4();
- }
+ public static native String getRelease();
/**
* Version level of the operating system.
*/
- public static String getVersion()
- {
- return get5();
- }
+ public static native String getVersion();
/**
* CPU count.
*/
- public static int getNumCpu()
- {
- return get1();
- }
+ public static native int getNumCpu();
/**
* Data model (32 or 64 bit).
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java?rev=1091129&r1=1091128&r2=1091129&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/util/UUID.java Mon Apr 11 17:07:49 2011
@@ -21,7 +21,7 @@ package org.apache.commons.runtime.util;
*/
public final class UUID
{
- private static native byte[] getb0();
+ private static native byte[] init0();
private byte[] uuid;
/**
@@ -29,7 +29,7 @@ public final class UUID
*/
public UUID()
{
- uuid = getb0();
+ uuid = init0();
}
public UUID(byte[] uuid)
@@ -48,6 +48,11 @@ public final class UUID
return h.substring(h.length() - 2);
}
+ public byte[] toArray()
+ {
+ return uuid;
+ }
+
public String toString()
{
// TODO: Make more optimized version
Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c?rev=1091129&r1=1091128&r2=1091129&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/os.c Mon Apr 11 17:07:49 2011
@@ -23,13 +23,13 @@ static struct utsname _sys_buf;
static int _sys_ncpu = 0;
static const char _unknown[] = "unknown";
-ACR_JNI_EXPORT(jint, Os, get0)(JNI_STDARGS)
+ACR_JNI_EXPORT(jint, Os, getType)(JNI_STDARGS)
{
UNREFERENCED_STDARGS;
return ACR_OS_LINUX;
}
-ACR_JNI_EXPORT(jint, Os, get1)(JNI_STDARGS)
+ACR_JNI_EXPORT(jint, Os, getNumCpu)(JNI_STDARGS)
{
UNREFERENCED_STDARGS;
if (_sys_ncpu == 0) {
@@ -54,12 +54,12 @@ ACR_JNI_EXPORT(jint, Os, init)(JNI_STDAR
return 0;
}
-ACR_JNI_EXPORT(jstring, Os, get2)(JNI_STDARGS)
+ACR_JNI_EXPORT(jstring, Os, getSysname)(JNI_STDARGS)
{
return CSTR_TO_JSTRING("linux");
}
-ACR_JNI_EXPORT(jstring, Os, get3)(JNI_STDARGS)
+ACR_JNI_EXPORT(jstring, Os, getNodename)(JNI_STDARGS)
{
if (_sys_done == 0)
return CSTR_TO_JSTRING(_sys_buf.nodename);
@@ -67,7 +67,7 @@ ACR_JNI_EXPORT(jstring, Os, get3)(JNI_ST
return CSTR_TO_JSTRING(_unknown);
}
-ACR_JNI_EXPORT(jstring, Os, get4)(JNI_STDARGS)
+ACR_JNI_EXPORT(jstring, Os, getRelease)(JNI_STDARGS)
{
if (_sys_done == 0)
return CSTR_TO_JSTRING(_sys_buf.release);
@@ -75,7 +75,7 @@ ACR_JNI_EXPORT(jstring, Os, get4)(JNI_ST
return CSTR_TO_JSTRING(_unknown);
}
-ACR_JNI_EXPORT(jstring, Os, get5)(JNI_STDARGS)
+ACR_JNI_EXPORT(jstring, Os, getVersion)(JNI_STDARGS)
{
if (_sys_done == 0)
return CSTR_TO_JSTRING(_sys_buf.version);
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/native.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/native.c?rev=1091129&r1=1091128&r2=1091129&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/native.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/native.c Mon Apr 11 17:07:49 2011
@@ -36,7 +36,7 @@ ACR_JNI_EXPORT(jboolean, Native, init0)(
return _loaded;
}
-ACR_JNI_EXPORT(void, Native, clr0)(JNI_STDARGS)
+ACR_JNI_EXPORT(void, Native, finalize0)(JNI_STDARGS)
{
if (_loaded) {
_loaded = JNI_FALSE;
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/uuid.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/uuid.c?rev=1091129&r1=1091128&r2=1091129&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/uuid.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/uuid.c Mon Apr 11 17:07:49 2011
@@ -17,13 +17,13 @@
#include "acr/jniapi.h"
#include "acr/port.h"
-ACR_UTIL_EXPORT(jbyteArray, UUID, getb0)(JNI_STDARGS)
+ACR_UTIL_EXPORT(jbyteArray, UUID, init0)(JNI_STDARGS)
{
unsigned int bb[4];
jbyteArray rv;
rv = (*_E)->NewByteArray(_E, 16);
- if (rv) {
+ if (rv != 0) {
bb[0] = arc4random();
bb[1] = arc4random();
bb[2] = arc4random();